defaults property

  1. @Deprecated('Use `MapperContainer.globals` instead. See $_containerIssueLink. ' 'May be removed in a future version.')
MapperContainer defaults
final

A container that holds the standard set of mappers for all core types, including all primitives, List, Set, Map and DateTime.

All other container will automatically be linked to this container.

Implementation

@Deprecated(
    'Use `MapperContainer.globals` instead. See $_containerIssueLink. '
    'May be removed in a future version.')
static final MapperContainer defaults = _MapperContainerBase._({
  PrimitiveMapper<Object>((v) => v, dynamic),
  PrimitiveMapper<Object>((v) => v, Object),
  PrimitiveMapper<String>((v) => v.toString()),
  PrimitiveMapper<int>((v) => num.parse(v.toString()).round()),
  PrimitiveMapper<double>((v) => double.parse(v.toString())),
  PrimitiveMapper<num>((v) => num.parse(v.toString()), num),
  PrimitiveMapper<bool>((v) => v is num ? v != 0 : v.toString() == 'true'),
  DateTimeMapper(),
  IterableMapper<List>(<T>(i) => i.toList(), <T>(f) => f<List<T>>()),
  SetMapper<Set>(<T>(i) => i.toSet(), <T>(f) => f<Set<T>>()),
  MapMapper<Map>(<K, V>(map) => map, <K, V>(f) => f<Map<K, V>>()),
  //RecordMapper(),
});