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:

@DriftAccessor()
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:

Constructors

DriftAccessor({List<Type> tables = 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.
const

Properties

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 accessed by this DAO.
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