read<T extends Object?> static method

T? read<T extends Object?>(
  1. String key,
  2. Map data, {
  3. String separator = "/",
})

Safely reads a value of type T from a nested Map using key and separator.

Returns null if the key does not exist or if the value is not of type T.

Implementation

static T? read<T extends Object?>(
  String key,
  Map data, {
  String separator = "/",
}) {
  if (key.isEmpty || data.isEmpty || separator.isEmpty) return null;

  final x = _read(key, data, separator);
  if (x is T) return x;
  return null;
}