moor_db_viewer
这个包允许我们在开发应用中查看我们的数据库,而无需导出数据库文件。过滤在数据库级别完成。

设置
将依赖项添加到 pubspec
dependencies:
moor_db_viewer: <latest-version>
使用它
推送一个新的路由。子组件将是 MoorDbViewer,并将您的数据库传递给此屏幕。
final db = MyDatabase(); //This should be a singleton
Navigator.of(context).push(MaterialPageRoute(builder: (context) => MoorDbViewer(db)));
Moor 配置
使用命名列
在使用命名列时,您应该在列上添加 @JsonKey,否则我们将无法隐藏此表
class Todos extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get title => text().withLength(min: 6, max: 32)();
@JsonKey('body') //This is required for the moor_db_viewer.
TextColumn get content => text().named('body')();
IntColumn get category => integer().nullable()();
}