Search code examples
flutterflutter-dependenciesubuntu-20.04sqfliteflutter-desktop

Flutter cannot find SQFLite databases path in Ubuntu Linux


I am working on a notes app and using VS code in Ubuntu 20.04 I have integrated the SQFLite and path plugins but I am getting the exception

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

Here is the integration of plugins

sqflite: ^2.0.2
path: ^1.8.0

These are the imports for these plugins

import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';

And here is the way I am accessing databases paths

Database db = await openDatabase(join(await getDatabasesPath(), "notes.db"),
    onCreate: ((db, version) async {
  await db.execute('''
  CREATE TABLE $tableName (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    $col1Name TEXT,
    $col2Name TEXT,
    $col3Name DATE
  )
  ''');
}), version: 1);

I have tried flutter clean but it is also not working


Solution

  • sqflite plugin is not supported on linux, you need to use the sqflite_common_ffi package that works both for flutter and dart VM on linux. More information here