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


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


fromJson(S json) → D
Map a value from json to something understood by the data class.
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.
toJson(D value) → S
Map a value from the Data class to json.
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.


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