Flutter Persistence Library Drift (moor)

This document translated from moor_db_viewer | Flutter Package (pub. Dev)

Meat turn more than inadequate ~ generous comments

Look at the sample very NB, the documentation is a little thin.


moor_db_viewer

This package allows us to view our database in the APP we are developing without having to export database files. Database level filtering has been implemented.

The sample

The installation

Add dependencies in Pubspce

The latest version of pub is V5.0.0

dependencies:
  moor_db_viewer: <latest-version>
Copy the code

use

Pushes a new route onto the stack. The child component is the MoorDbViewer, which then passes your database to this screen.

final db = MyDatabase(); // This needs to be a singleton
Navigator.of(context).push(MaterialPageRoute(builder: (context) => MoorDbViewer(db)));
Copy the code

Moor Config

Using named columns

When using named columns, you need to append @jsonkey to the column otherwise you cannot hide the table.

class Todos extends Table { IntColumn get id => integer().autoIncrement()(); TextColumn get title => text().withLength(min: 6, max: 32)(); @jsonKey ('body') // (using named columns,) is required in moor_db_Viewer TextColumn get Content => text().named('body')(); IntColumn get category => integer().nullable()(); }Copy the code