$checkedConvert<T> function Null safety

T $checkedConvert<T>(
  1. Map map,
  2. String key,
  3. T castFunc(
    1. dynamic
    ),
  4. {Object? readValue(
    1. Map,
    2. String
    )?}
)

Helper function used in generated code when JsonSerializableGenerator.checked is true.

Should not be used directly.

Implementation

T $checkedConvert<T>(
  Map map,
  String key,
  T Function(dynamic) castFunc, {
  Object? Function(Map, String)? readValue,
}) {
  try {
    return castFunc(readValue == null ? map[key] : readValue(map, key));
  } on CheckedFromJsonException {
    rethrow;
  } catch (error, stack) {
    throw CheckedFromJsonException._(error, stack, map, key);
  }
}