drift
drift copied to clipboard
Got UI stuck when writting data to SQL
I have using used
LazyDatabase _openConnection() {
// the LazyDatabase util lets us find the right location for the file async.
return LazyDatabase(() async {
final dbFolder = await getApplicationDocumentsDirectory();
final file = File(p.join(dbFolder.path, 'chat2.sqlite'));
if (!await file.exists()) {
dbFolder.create();
}
// return NativeDatabase(file);
return NativeDatabase.createInBackground(file, setup: (rawDb) {
rawDb.execute('PRAGMA journal_mode=WAL;');
});
});
}
NativeDatabase.createInBackground
created the database, but still, when inserting data to DB, the UI will stuck.
Is there any else reason could lead to this?