useAdapter method

JsonMapper useAdapter(
  1. IJsonMapperAdapter adapter, [
  2. int? priority
])

Registers an instance of IJsonMapperAdapter with the mapper engine Adapters are meant to be used as a pluggable extensions, widening the number of supported types to be seamlessly converted to/from JSON

Implementation

JsonMapper useAdapter(IJsonMapperAdapter adapter, [int? priority]) {
  if (_adapters.containsValue(adapter)) {
    return this;
  }
  final nextPriority = priority ??
      (_adapters.keys.isNotEmpty
          ? _adapters.keys.reduce((value, item) => max(value, item)) + 1
          : 0);
  _adapters[nextPriority] = adapter;
  _updateInternalMaps();
  return this;
}