drift icon indicating copy to clipboard operation
drift copied to clipboard

Got UI stuck when writting data to SQL

Open lucasjinreal opened this issue 6 months ago • 7 comments

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?

lucasjinreal avatar Aug 10 '24 03:08 lucasjinreal