tekartik / sqflite

SQLite flutter plugin
BSD 2-Clause "Simplified" License
2.88k stars 526 forks source link

on flutter windows the app works well on debug but on released mode packaged with installer it doesnt work #816

Closed Galzysoft closed 2 years ago

Galzysoft commented 2 years ago

the windows software I build with it is working very well on flutter debug mode or on released mode using the distribution folder method but I currently noticed that when I packaged the app with an installer (inno setup.exe and msix package ) I noticed that the database cant connect i also downloaded the sqlite3.dll file as you suggested in the documentation

humam-alBasha commented 2 years ago

add this in pubspec.yaml sqlite3_flutter_libs:

databaseHelper.dart ==> use

_initDatabase() async {
    DatabaseFactory _databaseFactory;
    String path = '';
    if (!kIsWeb && Platform.isWindows) {
      sqfliteFfiInit();
      _databaseFactory = databaseFactoryFfi;
      final Directory _directory = await getApplicationSupportDirectory();
      await _databaseFactory.setDatabasesPath(_directory.path);
      path = join(await _databaseFactory.getDatabasesPath(), "name.db");
    } else {
      _databaseFactory = databaseFactory;
      path = join(await _databaseFactory.getDatabasesPath(), "name.db");
    }
    _database = await _databaseFactory.openDatabase(path,
        options: OpenDatabaseOptions(
            onCreate: (Database db, int _) => _createDb(db), version: 1));

    return _database;
  }
Galzysoft commented 2 years ago

Thanks this solve my problem thanks

himanshuchaurasiya24 commented 9 months ago

add this in pubspec.yaml sqlite3_flutter_libs:

databaseHelper.dart ==> use

_initDatabase() async {
  DatabaseFactory _databaseFactory;
  String path = '';
  if (!kIsWeb && Platform.isWindows) {
    sqfliteFfiInit();
    _databaseFactory = databaseFactoryFfi;
    final Directory _directory = await getApplicationSupportDirectory();
    await _databaseFactory.setDatabasesPath(_directory.path);
    path = join(await _databaseFactory.getDatabasesPath(), "name.db");
  } else {
    _databaseFactory = databaseFactory;
    path = join(await _databaseFactory.getDatabasesPath(), "name.db");
  }
  _database = await _databaseFactory.openDatabase(path,
      options: OpenDatabaseOptions(
          onCreate: (Database db, int _) => _createDb(db), version: 1));

  return _database;
}

can you provide your full code