decodeSync<T> static method

T decodeSync<T>(
  1. List<int> value,
  2. Decodable<T> decodable
)

Implementation

static T decodeSync<T>(List<int> value, Decodable<T> decodable) {
  final lines = _LineSplitter.convert(value);

  Map<int, _ReferenceValue>? refs = {};

  final marker = refs[0] = _SyncReferenceValue(); // Initialize with a value for marker 0

  for (final line in lines) {
    if (line.isEmpty) {
      continue; // Skip empty lines
    }
    _parseBytes(line, refs, true);
  }

  late T result;

  marker.decode<T>(decodable).get((v) => result = v);

  return result;
}