1

I am using sqflite ffi for my database on desktop windows. I setup everything like in the sample. The application is working on debug built but if I run the application on release mode I'm getting the error in sqfliteFfiInit(). How can I fix that?

Invalid argument(s): Failed to load dynamic library (126)
Future<void> init() async {
  try {
    sqfliteFfiInit();
    
  } catch (e) {
    print(e.toString());  
  }
  _databaseFactory = databaseFactoryFfi;

   String path = '${await _databaseFactory.getDatabasesPath()}\\myDB.db';
   _db = await _databaseFactory.openDatabase(path);

   final List<Map<String, dynamic>> result = await _db.query(
     'sqlite_master',
      where: 'name = ?',
      whereArgs: <String>['MyDB'],
    );

    if(result.isEmpty){
      await _db.execute('''
CREATE TABLE MyDB (
  id INTEGER PRIMARY KEY,
  name TEXT
)
''');
  }
}
Richard Heap
  • 48,344
  • 9
  • 130
  • 112
quoci
  • 2,940
  • 1
  • 9
  • 21

1 Answers1

6

The sqflite ffi github page says:

"In release mode, add sqlite3.dll in same folder as your executable."

Dharman
  • 30,962
  • 25
  • 85
  • 135
Diego
  • 114
  • 3
  • 2
    This works fine. But what about exporting using MSIX? In that we can not place under windows apps folder. – Dipen Patel Mar 04 '22 at 12:34
  • I added that file as the Github page says, still getting "FileSystemException: Cannot open file", whereas it's working fine in debug mode... any idea? – Harsha Vardhan Jun 07 '22 at 16:37
  • Did anyone ever figure out how to make this work in release mode when generating an MSIX package for Windows? – Clifton Labrum Apr 03 '23 at 19:30
  • 1
    @CliftonLabrum Hey it seems you found a solution for the msix package. I saw it here: https://github.com/tekartik/sqflite/issues/945#issuecomment-1515310817 Thanks. – Umut Aug 23 '23 at 09:31