$optional<T> method

T? $optional<T>(
  1. String key,
  2. T? read(
    1. Object? value,
    2. String path
    )
)

Optional property key, converted by read; null when absent or null.

Implementation

T? $optional<T>(String key, T? Function(Object? value, String path) read) {
  final value = _json[key];
  if (value == null) return null;
  return read(value, '$runtimeType.$key');
}