Closed pradeepjunglee closed 5 months ago
Hard to help without seeing some code.
Please check and ensure that:
Solutions:
path_provider
package to find the best location for you database (getDatabasesPath()
is only relevant for Android)join
from the path
package)Hi @alextekartik, thank you for the swift reply. The path_provider helped resolve the issue. I've included the code snippet below in case anyone else encounters this problem:
import 'package:path_provider/path_provider.dart';
import 'package:sqflite/sqflite.dart' as sqflite;
import 'package:path/path.dart' as path;
Future<AppDatabase> build() async {
final Directory documentsDirectory = await getApplicationDocumentsDirectory();
await documentsDirectory.create(recursive: true);
final dbPath = name != null
? Platform.isMacOS
? path.join(documentsDirectory.path, name)
: await sqfliteDatabaseFactory.getDatabasePath(name!)
: ':memory:';
final database = _$AppDatabase();
database.database = await database.open(
dbPath,
_migrations,
_callback,
);
return database;
}
flutter doctor -v