DriftAccessor class Null safety

Annotation to use on classes that implement DatabaseAccessor. It specifies which tables should be made available in this dao.

To write a dao, you'll first have to write a database class. See DriftDatabase for instructions on how to do that. Then, create an empty class that is annotated with DriftAccessor and extends DatabaseAccessor. For instance, if you have a class called MyDatabase, this could look like this:

class MyDao extends DatabaseAccessor<MyDatabase> {
  MyDao(MyDatabase db) : super(db);

After having run the build step once more, drift will have generated a mixin called _$MyDaoMixin. Change your class definition to class MyDao extends DatabaseAccessor<MyDatabase> with _$MyDaoMixin and you're ready to make queries inside your dao. You can obtain an instance of that dao by using the getter that will be generated inside your database class.

See also:


DriftAccessor({List<Type> tables = const [], List<Type> views = const [], Map<String, String> queries = const {}, Set<String> include = const {}})
Annotation for a class to declare it as an dao. See DriftAccessor and the referenced documentation on how to use daos with drift.


hashCode int
The hash code for this object.
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.
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.
runtimeType Type
A representation of the runtime type of the object.
tables List<Type>
The tables accessed by this DAO.
views List<Type>
The views to make accessible in this DAO.


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


operator ==(Object other) bool
The equality operator.