create instance #1869
Unanswered
abbasihamed
asked this question in
Q&A
create instance
#1869
Replies: 1 comment
-
You'd have to use conditional imports to pick the right import 'package:drift/drift.dart';
QueryExecutor connect() {
throw UnsupportedError(
'No suitable database implementation was found on this platform.');
} In import 'package:drift/drift.dart';
// ...
QueryExecutor connect() {
return LazyDatabase(() async {
// load right path with path_provider
return NativeDatabase(dbFile);
});
} In import 'package:drift/web.dart';
QueryExecutor connect() {
return WebDatabase('your_app');
} In export 'unsupported.dart'
if (dart.library.html) 'web.dart'
if (dart.library.ffi) 'native.dart'; Then, import |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I use this package for both platforms (web and mobile) and when I want to create an instance from the AppDataBase class, it gives me an error because I have to add some value to the class constructor.
How can I do this without making a mistake?
Beta Was this translation helpful? Give feedback.
All reactions