CommentTag class final

Represents a comment metadata tag for audio files.

CommentTag contains free-form comment or description text about the track. Unlike other metadata fields, comments are typically longer-form text and may include multiple sentences, notes, or additional information about the audio content.

Format mappings:

  • ID3v2: COMM frame (with language and description)
  • Vorbis: COMMENT field
  • MP4: ©cmt atom
  • ID3v1: Comment field (30 chars, or 28 if track number present)

Example usage:

// Create a basic comment tag
final commentTag = CommentTag('Recorded live at Madison Square Garden');

// Create with provenance information
final commentWithProvenance = CommentTag(
  'Recorded live at Madison Square Garden',
  provenance: TagProvenance(
    ContainerKind.id3v2,
    '2.4',
    TagConfidence.certain,
  ),
);

// Update provenance immutably
final updatedTag = commentTag.withProvenance(
  TagProvenance(ContainerKind.vorbis, '', TagConfidence.certain),
);

The comment value should be a string containing descriptive text. Different container formats may have length limitations that are handled automatically during encoding operations. ID3v1 has particularly strict limits (30 characters, or 28 if track number is present).

Inheritance

Constructors

CommentTag(String value, {TagProvenance provenance = const TagProvenance.none()})
Creates a new CommentTag with the specified comment value.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
key TagKey
The semantic field type that this tag represents.
finalinherited
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setterinherited
provenance TagProvenance
Provenance information tracking the origin and reliability of this tag.
finalinherited
requiresAsyncPreparation bool
Whether this tag requires async data loading before encoding.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited
value String
The actual metadata value stored in this tag.
finalinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prepareForEncoding() Future<MetadataTag<String>>
Prepares the tag for synchronous encoding by loading any async data.
inherited
prepareForEncodingAsync() Future<MetadataTag<String>>
Prepares the tag for synchronous encoding by loading any async data.
inherited
toJson() Map<String, dynamic>
Converts this CommentTag to a JSON-serializable Map.
toString() String
A string representation of this object.
inherited
withProvenance(TagProvenance newProvenance) CommentTag
Creates a new CommentTag instance with updated provenance information.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromJson(Map<String, dynamic> json) CommentTag
Creates a CommentTag from a JSON Map.