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 (var i = 0; i < _fields.length; i++) {
    var name = _fields[i].key;
    var t = _fields[i].value;
    if (x.containsKey(name)) {
      final idx = lebEncode(i);
      return u8aConcat(
        [idx, tryToJson(t, x[name]) ?? t.encodeValue(x[name])],
      );
    }
  }
  throw 'Variant has no data: $x';
}