【发布时间】:2021-10-28 13:47:46
【问题描述】:
class Word {
int? id;
late String word;
late String description;
Word({required this.word, required this.description});
Word.withId({this.id, required this.word, required this.description});
Map<String,dynamic> toMap(){
var map = Map<String,dynamic>();
map["word"] = word;
map["description"] = description;
if (id!=null) {
map["id"] = id;
}
}
。 . .
Future<int?> insert(Word word) async {
/// db ekleme sorgusu
Database? db = await this.db;
/// database erişim
var result = await db!.insert("words", word.toMap());
return result;
}
我在将 Map 用于此代码块时遇到此错误,有人可以帮忙吗? ????
错误:主体可能正常完成,导致返回“null”,但返回类型可能是不可为空的类型。 (body_might_complete_normally at [sqflite_demo] lib\models\word.dart:9)
【问题讨论】: