getConverter method

JsonConverter getConverter(
  1. TypeInfo type
)

Retrieves the appropriate converter for the given type.

First checks custom converters, then falls back to default converters.

@param type The type information to find a converter for. @returns The JsonConverter that can handle the specified type. @throws StateError if no converter is found for the type.

Implementation

JsonConverter getConverter(TypeInfo type) {
  return converters.where((converter) => converter.canConvert(type)).firstOrNull ??
      defaultConverters.firstWhere((converter) => converter.canConvert(type));
}