JsonTypeConverter2<D, S, J> mixin Null safety

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

Unlike the old JsonTypeConverter mixin, this more general mixin allows using a different type when serializing to JSON (J) than the type used in SQL (S). For the cases where the JSON serialization and the mapping to SQL use the same types, it may be more convenient to mix-in JsonTypeConverter instead.

Superclass Constraints
Mixin Applications


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


fromJson(J 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 non-existent method or property is accessed.
toJson(D value) → J
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.

Static Methods

asNullable<D, S extends Object, J extends Object>(JsonTypeConverter2<D, S, J> inner) JsonTypeConverter2<D?, S?, J?>
Wraps an inner type converter that only considers non-nullable values as a type converter that handles null values too.