'sqflite no such table qcm in "INSERT INTO qcm

i am new and i ried to creat database for my project QCM maker i used flutter and sqlite its show me th erreur is no table caled qcm i dont know where is the problem and i dont know o much about sqlite the bease of utulisateur is working but whene i creat table qcm it dont work whene i try to add qcm

import 'package:login_signup_screen/modele/UserModel.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
import 'dart:io'as io;
import '../modele/QCMmodel.dart';
class DbHelper{
static Database _db;
static const String db_name ='test.db';
static const String table_user ='utilisateur';
static const int version=1;
static const String C_userID ='Nom_dutilisateur';
static const String C_usernom ='Nom';
static const String C_userprenom ='prenom';
static const String C_useremail ='email';
static const String C_usermotdepasse ='mot_de_passe';

static const String table_QCM ='qcm';
static const String C_id ='id';
static const String C_titre ='titre';
static const String C_module ='module';
static const int C_dure=0 ;


Future<Database> get db async{
if(_db!= null)
  {
    return _db;
  }
_db = await intdb();
return _db;
}
intdb () async{
io.Directory documentDiroctory = await  getApplicationDocumentsDirectory();
String path = join (documentDiroctory.path,db_name);
var db =await openDatabase(path,version: version, onCreate: _oncreate);
return db ;
}
_oncreate (Database db,int intVersion)async{
 await db.execute("CREATE TABLE $table_user("
    "$C_userID TEXT ,"
    "$C_usernom TEXT,"
    "$C_userprenom TEXT ,"
    "$C_useremail TEXT,"
    "$C_usermotdepasse TEXT ,"
    "PRIMARY KEY ($C_userID)"
 ")");
 await db.execute("CREATE TABLE $table_QCM("
    "$C_id TEXT ,"
    "$C_titre TEXT,"
    "$C_module TEXT ,"
    "$C_dure INTEGER ,"
    "PRIMARY KEY ($C_id)"
    ")");
 }
 Future<int> saveData(UserModel user)async{
 var dbutulisateur=await db;
 var res = await dbutulisateur.insert(table_user, user.toMap()) ;
 return res;
 }

 Future<UserModel> getLogin(String userId,String modepasse) async{
 var dbutulisateur = await db;
 var res = await dbutulisateur.rawQuery("SELECT * FROM $table_user WHERE "
 "$C_userID = '$userId' AND "
"$C_usermotdepasse = '$modepasse'");

 if(res.length>0){
  return UserModel.fromMap(res.first);
 }
 return null;
}

 Future<int> addQCM(qcmModel qcm)async{
 var dbQCM=await db;
 var res1 = await dbQCM.insert(table_QCM, qcm.toMap()) ;
 return res1;
}

}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source