putTagsToByteArray method

Future<List<int>> putTagsToByteArray(
  1. Future<List<int>?> bytes, [
  2. List<Tag>? tags
])

Implementation

Future<List<int>> putTagsToByteArray(Future<List<int>?> bytes,
    [List<Tag>? tags]) async {
  if (await bytes == null) {
    throw ParsingException(ParsingException.byteArrayNull);
  }
  var b = (await bytes)!;

  if (tags == null || tags.isEmpty) {
    for (var w in _writers.values) {
      b = await w.removeExistingTag(b);
    }

    return b;
  }

  for (var t in tags) {
    final w = _writers[getTagType(t.type!, t.version)]!;
    b = await w.write(b, t);
  }

  return b;
}