JsonTypeConverter<D, S> mixin

A mixin for TypeConverters that should also apply to drift's builtin JSON serialization of data classes.

By default, a TypeConverter only applies to the serialization from Dart to SQL (and vice-versa). When a BuildGeneralColumn.map column (or a MAPPED BY constraint in .drift files) refers to a type converter that inherits from JsonTypeConverter, it will also be used for the conversion from and to JSON.

If the serialized JSON has a different type than the type in SQL (S), use a JsonTypeConverter2. For instance, this could be useful if your type converter between Dart and SQL maps to a string in SQL, but to a Map in JSON.

Implemented types
Mixin Applications

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

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

Operators

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