在 moor flutter 中,关键字select, into, update, delete
显示错误如下-
错误:无法推断类型参数“R”。试图推断“R”的“列表”不起作用:类型参数“R”声明为扩展“DataClass”。'Lists' 类型推断自:参数 'table' 声明为 'TableInfo' 但参数是 '$ListsTable'。考虑将显式类型参数传递给泛型。
import 'package:moor_flutter/moor_flutter.dart';
import 'package:moor/moor.dart';
part 'List.g.dart';
@DataClassName('Lists')
class Lists extends Table{
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text().withLength(min:1, max: 50)();
DateTimeColumn get date => dateTime().nullable()();
BoolColumn get strikeThrough => boolean().withDefault(Constant(false))();
}
@UseMoor(tables: [Lists])
class AppDatabase extends _$AppDatabase {
AppDatabase(): super((FlutterQueryExecutor.inDatabaseFolder(path:'db.sqlite',logStatements:true)));
@override
int get schemaVersion => 1;
Future<List<Lists>> getAllLists() => select(lists).get();
Stream<List<Lists>> watchAllLists() => select(lists).watch();
Future insertLists(Lists list) => into(lists).insert(list);
Future updateLists(Lists list) => update(lists).replace(list);
Future deleteLists(Lists list) => delete(lists).delete(list);
}