的数据
这个[ int = int?]我知道这是一个错误,
但是[ FutureOr func()= FutureOr func()?]
我不明白
func()和func()?
有谁能告诉我这是怎么回事吗?
下面是有问题的代码:
// create a getter to instantiate the database obj
Future<Database> get database async {
// initialize the database when uninitialized
if (_database != null) return _database!;
_database = await _initDB('students.db');
return _database!;
}
Future<Database> _initDB(String filePath) async {
final dbPath = await getDatabasesPath();
final path = join(dbPath, filePath);
return await openDatabase(path, version: 1, onCreate: _createDB);
}
FutureOr<void> _createDB(Database db, int version) async {
const String idType = 'INTEGER PRIMARY KEY AUTOINCREMENT';
const String textType = 'TEXT NOT NULL';
const String boolType = 'BOOLEAN NOT NULL';
const String intType = 'INTEGER NOT NULL';
const String telephoneType = 'INTEGER NOT NULL';
const String studentID = 'StudentId';
const String studentFirstName = 'studentFirstName';
const String studentMiddleName = 'studentMiddleName';
const String studentLastName = 'studentLastName';
const String studentAge = 'studentAge';
const String studentGender = 'studentGender';
const String studentHometown = 'studentHometown';
const String studentLocation = 'studentLocation';
return await db.execute('''
CREATE TABLE Students(
$studentID $idType,
$studentFirstName $textType,
$studentMiddleName $textType,
$studentLastName $textType,
$studentAge $intType,
$studentGender $textType,
$studentHometown $textType,
$studentLocation $textType,
)
''');
}
字符串
这里的图像也更好的语法突出显示
的
2条答案
按热度按时间yvfmudvl1#
我相信你必须改变
_createdDB
,它的返回类型是Future<void>
,你返回db.execute
函数。只需删除return
语句。字符串
rryofs0p2#
我相信你必须将这些返回类型改为可空的
Database?
字符串