covariant method

  1. @override
bool covariant(
  1. dynamic x
)
override

Assert that JavaScript's x is the proper type represented by this Type.

Implementation

@override
bool covariant(dynamic x) {
  if (x is! Map) {
    try {
      x = x.toJson();
    } catch (e) {
      return false;
    }
  }
  return _fields.every((entry) {
    final k = entry.key;
    final t = entry.value;
    if (!x.containsKey(k)) {
      throw StateError("Record is missing the key '$k'.");
    }
    return t.covariant(x[k]);
  });
}