set method

void set({
  1. required dynamic value,
  2. required String key,
  3. String? desc,
})

Implementation

void set({required dynamic value, required String key, String? desc}) {
  final lastContainer = _getContainer();
  if (lastContainer != null) {
    if (lastContainer is List) {
      List list = lastContainer;
      list.add({key: _ID3MetadataValue(value: value, desc: desc)});
      List tagList = _getTagMapContainer();
      tagList.add({key: _unwrapperValue(value)});
    } else if (lastContainer is Map) {
      Map map = lastContainer;
      map[key] = _ID3MetadataValue(value: value, desc: desc);
      Map tagMap = _getTagMapContainer();
      tagMap[key] = _unwrapperValue(value);
    } else {
      assert(false, "Unknown container: $lastContainer.");
    }
  } else {
    _metadata[key] = _ID3MetadataValue(value: value, desc: desc);
    _tagMap[key] = _unwrapperValue(value);
  }
}