will you support Stetho for easily access sqlite db?
zinwalin opened this issue · 2 comments
zinwalin commented
I tried to integrate Stetho and sqflite, so I can debug and access sqlite db from Chrome Dev Tools, but it seems sqflite and Stetho doesn't work together at the moment.
sidlatau commented
I was able to access database via Chrome Dev Tools. Point is that when creating database I used Directory path = await getApplicationDocumentsDirectory();
. But it returns appRoot/app_flutter
directory. Stetho expects databases in appRoot/databases
directory. So the trick is to create database file in databases
directory:
Future<String> _getPath() async {
Directory path = await getApplicationDocumentsDirectory();
if (Platform.isAndroid) {
return join(path.parent.path, "databases/db.sqlite");
} else {
return join(path.path, "db.sqlite");
}
}
...
_db = await openDatabase(
dbPath,
version: 1,
onCreate: _create,
);