maybeFrom static method

ExpandedReference? maybeFrom(
  1. Object? value
)

Reads a single reference out of a decoded record value. Answers null when the value is not an expanded reference — for instance the plain id a read without expandReferences returns, or a missing field.

Implementation

static ExpandedReference? maybeFrom(Object? value) {
  if (value is Map<String, dynamic> && value.containsKey('id')) {
    return ExpandedReference.fromJson(value);
  }
  if (value is Map && value.containsKey('id')) {
    return ExpandedReference.fromJson(Map<String, dynamic>.from(value));
  }
  return null;
}