encodeValue method

  1. @override
Uint8List encodeValue(
  1. Map<String, dynamic> x
)
override

Encode the value. This needs to be public because it is used by encodeValue() from different types. @internal

Implementation

@override
Uint8List encodeValue(Map<String, dynamic> x) {
  for (int i = 0; i < _fields.length; i++) {
    final name = _fields[i].key;
    final t = _fields[i].value;
    if (x.containsKey(name)) {
      final idx = lebEncode(i);
      return u8aConcat(
        [idx, tryToJson(t, x[name]) ?? t.encodeValue(x[name])],
      );
    }
  }
  throw StateError('variant has no data: $x.');
}