my app work without any error in the debug mode in the emulator but in my android physical device the sqflite didn't work how can i fix this it's there an option i can do before the release or what i searched alot without any sol this is the most code of the sqflite:
class TodoDb {
RxList<Map>? data;
static Database? _db;
RxInt completed=0.obs;
Future<Database?> get db async{
if(_db==null){
_db=await instial();
return _db;
}
return _db;
}
instial () async{
String databasepath=await getDatabasesPath();
String path= p.join(databasepath, "local.db");
Database mydb = await openDatabase(path, onCreate: _onCreate, version: 1);
return mydb;
}
_onCreate (Database db, int version)async{
await db.execute('''
CREATE TABLE "todo" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT ,
"task" TEXT NOT NULL ,
"icon" INTEGER NOT NULL ,
"isDone" BOOLEAN NOT NULL
)
''');
print("ONCREATE ####################################");
}
readData()async{
Database? mydb=await db;
List<Map> res= await mydb!.rawQuery("SELECT * FROM 'todo'");
data=res.obs;
await checkDay();
return data!.length;
}
insertData(String task, int icon)async{
Database? mydb=await db;
int response= await mydb!.rawInsert('INSERT INTO todo(task, icon, isDone) VALUES("$task", $icon, false)');
return response;
}
}
when i connect my phone i get this error:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DatabaseException(no such column: false (Sqlite code 1 SQLITE_ERROR): , while compiling: INSERT INTO todo(task, ico
n, isDone) VALUES("guy", 57733, false), (OS error - 2:No such file or directory)) sql 'INSERT INTO todo(task, icon, isDone) VALUES("guy", 57733, false)' args []
bool is not a supported SQLite type. Use INTEGER and 0 and 1 values. and make sure to install the app after uninstalling older version to create the DB on first run.