floor icon indicating copy to clipboard operation
floor copied to clipboard

Could not use on linux

Open erikseifert opened this issue 4 years ago • 4 comments

 no handler found for channel com.tekartik.sqflite

Seems to get the correct ffi implementation but throws everytime this error.

erikseifert avatar Aug 07 '20 10:08 erikseifert

Which libraries are you using and what're their versions? Have you run flutter packages pub upgrade?

vitusortner avatar Aug 10 '20 19:08 vitusortner

 no handler found for channel com.tekartik.sqflite

Seems to get the correct ffi implementation but throws everytime this error.

@erikseifert I have solved the problem modyfied method build() in class _$AppDatabaseBuilder. not use sqfliteDatabaseFactory.getDatabasePath but path_provider to get path as following. @vitusortner hope you fix it in plugin code.

/// import path_provider
import 'package:path_provider/path_provider.dart' as path_provider;

/// Creates the database and initializes it.
Future<AppDatabase> build() async {
  var path = ':memory:';
  if (name != null) {
    if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
      path = normalize(join((await path_provider.getApplicationDocumentsDirectory()).path, 'myAppName', name));
    } else {
      path = await sqfliteDatabaseFactory.getDatabasePath(name);
    }
  }
  final database = _$AppDatabase();
  database.database = await database.open(
    path,
    _migrations,
    _callback,
  );
  return database;
}
  

mabDc avatar Oct 23 '20 08:10 mabDc

i found another solution. just use setDatabasesPath, and all work fine.

import 'package:sqflite/sqflite.dart' as sqflite;
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:sqflite/src/factory_mixin.dart' as impl;


sqflite.databaseFactory = databaseFactoryFfi;
final factory = sqflite.databaseFactory as impl.SqfliteDatabaseFactoryMixin;
factory.setDatabasesPath("your/app/path");

mabDc avatar Oct 24 '20 18:10 mabDc

Does this problem still exist?

mqus avatar Apr 23 '21 13:04 mqus