register<T> static method

void register<T>({
  1. required JsonFactory<T> fromJson,
  2. required JsonEncoder<T> toJson,
})

Registers conversion functions for a specific type.

Implementation

static void register<T>({
  required JsonFactory<T> fromJson,
  required JsonEncoder<T> toJson,
}) {
  _factories[T] = (Map<String, dynamic> json) => fromJson(json);
  _encoders[T] = (dynamic value) => toJson(value as T);
}