TypeConverter<D, S> class abstract

Maps a custom dart object of type D into a primitive type S understood by the sqlite backend.

Dart currently supports DateTime, double, int, Uint8List, bool and String for S.

Using a type converter does not impact the way drift serializes data classes to JSON by default. To control that, use a JsonTypeConverter or a custom ValueSerializer.

Also see BuildGeneralColumn.map for details.

Implementers

Constructors

TypeConverter()
Empty constant constructor so that subclasses can have a constant constructor.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

fromSql(S fromDb) → D
Maps a column from the database back to Dart.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toSql(D value) → S
Map a value from an object in Dart into something that will be understood by the database.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

extensionType<ExtType, Inner extends Object>() JsonTypeConverter<ExtType, Inner>
A type converter mapping extension types to their underlying representation to store them in databases.
json<D>({required D fromJson(dynamic json), dynamic toJson(D column)?, JsonCodec json = convert.json}) JsonTypeConverter<D, String>
Creates a type converter for storing complex Dart objects in a text column by serializing them as JSON.