DriftDatabase class Null safety

Use this class as an annotation to inform the generator that a database class should be generated using the specified DriftDatabase.tables.

To write a database class, first annotate an empty class with DriftDatabase and run the build runner using dart pub run build_runner build. Drift will have generated a class that has the same name as your database class, but with _$ as a prefix. You can now extend that class and provide a QueryExecutor to use drift:

class MyDatabase extends _$MyDatabase { // _$MyDatabase was generated
  MyDatabase():
    super(FlutterQueryExecutor.inDatabaseFolder(path: 'path.db'));
}

Constructors

DriftDatabase({List<Type> tables = const [], List<Type> daos = const [], Map<String, String> queries = const {}, Set<String> include = const {}})
Use this class as an annotation to inform the generator that a database class should be generated using the specified DriftDatabase.tables.
const

Properties

daos List<Type>
Optionally, the list of daos to use. A dao can also make queries like a regular database class, making is suitable to extract parts of your database logic into smaller components. [...]
final
hashCode int
The hash code for this object. [...]
read-only, inherited
include Set<String>
Defines the .drift files to include when building the table structure for this database. For details on how to integrate .drift files into your Dart code, see the documentation.
final
queries Map<String, String>
Optionally, a list of named sql queries. During a build, drift will look at the defined sql, figure out what they do, and write appropriate methods in your generated database. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
tables List<Type>
The tables to include in the database
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited