如何使用以下包在零安全的情况下运行
- 包:sqflite
- 包:sqflite_common
- 程序包:已同步
代码:
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');
});
}
错误消息:
错误:无法使用健全的null安全性运行,因为以下依赖项不支持null安全性:
- 包:sqflite
- 包:sqflite_common
- 程序包:已同步
所有三个软件包do在其最新版本中都支持声音零安全。
您没有显示您的pubspec.yaml,但我想您需要将这些包更新到最新版本。
要么将包更新到最新版本,要么使用--no-sound-null-safety
参数构建