'how to resolve sqflite error : MissingPluginException sqflite
I created my database with this function:
void CreateDatabase() async {
database = await openDatabase(
'todo.db',
version: 1,
onCreate: (database, version) {
print('database is created ');
database
.execute(
'CREATE TABLE tasks(id INTEGER PRIMARY KEY , title TEXT, date TEXT , time TEXT , Status Text )')
.then((value) {
print('table created');
}).catchError((error) {
print('error when creating table ${error.runtimeType}');
});
},
onOpen: (database) {
print('database is opned ');
},
);
}
Of course after installing dependencies in pubspec.yaml
dependencies:
flutter:
sdk: flutter
sqflite: ^1.3.0
Then, I called the function CreateDatabase();
but this error appear:
Error: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)
at Object.throw_ [as throw] (http://localhost:41319/dart_sdk.js:5375:11)
at MethodChannel._invokeMethod (http://localhost:41319/packages/flutter/src/services/system_channels.dart.lib.js:1551:21)
at _invokeMethod.next (<anonymous>)
at http://localhost:41319/dart_sdk.js:39799:33
at _RootZone.runUnary (http://localhost:41319/dart_sdk.js:39656:58)
at _FutureListener.thenAwait.handleValue (http://localhost:41319/dart_sdk.js:34585:29)
at handleValueCallback (http://localhost:41319/dart_sdk.js:35170:49)
at Function._propagateToListeners (http://localhost:41319/dart_sdk.js:35208:17)
at _Future.new.[_completeWithValue] (http://localhost:41319/dart_sdk.js:35050:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:41319/dart_sdk.js:35073:35)
at Object._microtaskLoop (http://localhost:41319/dart_sdk.js:39961:13)
at _startMicrotaskLoop (http://localhost:41319/dart_sdk.js:39967:13)
at http://localhost:41319/dart_sdk.js:35432:9
I called the function inside floating button:
floatingActionButton: FloatingActionButton(
onPressed: () {
CreateDatabase();
},
child: Icon(Icons.format_list_bulleted),
// fabIcon,
),
Did I miss any step in creating database?
Solution 1:[1]
A simple flutter clean
and flutter build
should fix it.
That happens when the dependencies are not embedded in the binary.
Solution 2:[2]
Status column type Text wrong, right status TEXT
Maybe
I change your code check your code
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Miguel Ruivo |
Solution 2 |