Search code examples
fluttersqflite

(MissingPluginException(No implementation found for method openDatabase on channel com.tekartik.sqflite)) flutter


(MissingPluginException(No implementation found for method openDatabase on channel com.tekartik.sqflite)) flutter

in internet thay say to force flutter clean + flutter pub get, but it didnt worked for me


Solution

  • I found the solution in my case. I was using construction:

    return await openDatabase(
      path,
      version: 1,
      onCreate: _onCreate,
      onUpgrade: (db, oldVersion, newVersion) => onUpdateTable(db),
    );
    

    Which was wrong, instead try

    sqfliteFfiInit();
    return await databaseFactoryFfi.openDatabase(
      path,
      options: OpenDatabaseOptions(
        version: 1,
        onCreate: _onCreate,
        onUpgrade: (db, oldVersion, newVersion) => onUpdateTable(db),
      ),
    );