Issue
How to run with the null safety using the following packages
- package:sqflite
- package:sqflite_common
- package:synchronized
Code:
void database() async {
// ignore: unused_local_variable
var database = await openDatabase('alimaher.db', version: 1,
onCreate: (database, vervion) {
// ignore: avoid_print
print('database created');
database
.execute(
'CREATE TABLE tasks (id INTEGER PRIMARY KEY,title TEXT, date TEXT,time TEXT,status TEXT ) ')
.then((value) {
// ignore: avoid_print
print('table created');
}).catchError((error) {
// ignore: avoid_print
print('error when creating table ${error.toString()}');
});
}, onOpen: (database) {
// ignore: avoid_print
print('database opened');
});
}
The error message:
Error: Cannot run with sound null safety, because the following dependencies don’t support null safety:
- package:sqflite
- package:sqflite_common
- package:synchronized
Solution
All three packages do support sound null-safety in their latest releases.
You did not show your pubspec.yaml, but I guess you will need to update those packages to their most recent versions.
Answered By – nvoigt
Answer Checked By – Willingham (FlutterFixes Volunteer)