getTagsFromByteData method

Future<List<Tag>> getTagsFromByteData(
  1. ByteData? bytes, [
  2. List<TagType>? types
])

Returns the tags from the ByteData

Implementation

Future<List<Tag>> getTagsFromByteData(ByteData? bytes,
    [List<TagType>? types]) async {
  if (bytes == null) {
    throw ParsingException(ParsingException.byteDataNull);
  }

  final tags = <Tag>[];
  final c = Completer<List<int>>.sync()
    ..complete(bytes.buffer.asUint8List().toList());

  if (types == null || types.isEmpty) {
    types = _readers.keys.toList();
  }

  for (var t in types) {
    tags.add(await _readers[t]!.read(c.future));
  }

  return tags;
}