You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@DriftDatabase(
tables: [SettingsTable, WalletsTable, TransactionsTable, CategoriesTable],
daos: [SettingsDAO, WalletsDAO, TransactionsDAO, CategoriesDAO])
classAppDatabaseextends_$AppDatabase {
AppDatabase([QueryExecutor? executor]) :super(executor ??_openConnection());
@overrideintget schemaVersion =>1;
@overrideMigrationStrategyget migration =>MigrationStrategy(
beforeOpen: (details) async {
if (details.wasCreated) {
// preloading settingsawaitinto(settingsTable).insert(
SettingsData(
id:1,
details:SettingsDetails.empty(),
),
);
CategoriesDAO.insertDefaultCategories(this);
}
},
);
}
LazyDatabase_openConnection() {
// the LazyDatabase util lets us find the right location for the file async.returnLazyDatabase(() async {
// put the database file, called db.sqlite here, into the documents folder// for your app.final dbFolder =awaitgetApplicationDocumentsDirectory();
final file =File(p.join(dbFolder.path, 'db.sqlite'));
returnNativeDatabase.createInBackground(file, logStatements:true);
});
}
@lazySingleton@DriftAccessor(tables: [CategoriesTable])
classCategoriesDAOextendsDatabaseAccessor<AppDatabase>
with_$CategoriesDAOMixin {
CategoriesDAO(AppDatabase attachedDatabase) :super(attachedDatabase);
staticFuture<void> insertDefaultCategories(AppDatabase database) async {
await database.computeWithDatabase(
computation: (database) async {
// Expensive computation that runs on its own isolate but talks to the// main database.final categories = categoryList;
database.batch((batch) => batch.insertAll(
database.categoriesTable, categories,
mode:InsertMode.insertOrReplace));
},
connect: (connection) {
// This function is responsible for creating a second instance of your// database class with a short-lived [connection].// For this to work, your database class needs to have a constructor that// allows taking a connection as described above.returnAppDatabase(connection);
},
);
}
}
The text was updated successfully, but these errors were encountered:
Describe the bug
I am trying to make a bulk insertion on database using isolate, so based on docs did this but getting the following error
My code:
The text was updated successfully, but these errors were encountered: