Skip to content

Add existing databases not work #1203

Discussion options

You must be logged in to vote

I fix with this code (this code didn't available on the moor docs or different within the moor docs)

/// This function for load db from the assets
LazyDatabase _openConnection() {
  return LazyDatabase(() async {
    /// put the database file, called db_orion.db here, into the documents folder for your app.
    final dbFolder = await getDatabasesPath();
    final file = File(join(dbFolder, 'db_orion'));

    if (!await file.exists()) {
      /// Extract the pre-populated database file from assets
      final blob = await rootBundle.load('assets/database/db_orion');
      await file.writeAsBytes(blob.buffer.asUint8List());
    }

    return FlutterQueryExecutor.inDatabaseFolder(
      path:

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@rrifafauzikomara
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by rrifafauzikomara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants