read static method

Future<Metadata?> read(
  1. String filePath, {
  2. bool createThumbnail = false,
})

Reads the metadata from the file at filePath.

If createThumbnail is true and filePath is a video file with no real embedded cover art, a thumbnail is generated by capturing a frame from the video itself (similar to what a file explorer or media player would show) — the same real content, never a generic file-type icon. When a thumbnail is generated this way, metadata.imageMetadata.isGenerated is true so callers can tell it apart from a genuine embedded cover. Defaults to false, since generating a thumbnail is more expensive than reading existing tags.

Returns null if the file is unreadable or unsupported. Throws ArgumentError if filePath is empty.

Implementation

static Future<Metadata?> read(String filePath, {bool createThumbnail = false}) async {
  if (filePath.trim().isEmpty) {
    throw ArgumentError('filePath must not be empty');
  }
  return MediaMetadataPlatform.instance.readMetadata(
    filePath,
    createThumbnail: createThumbnail,
  );
}