getMediaPath method

Future<String?> getMediaPath(
  1. String messageId
)

Returns the local file path for a message's media, or null if the file doesn't exist on disk.

Implementation

Future<String?> getMediaPath(String messageId) async {
  final dir = await _getMessageMediaDir(messageId);
  final msgDir = Directory(dir);

  if (!await msgDir.exists()) return null;

  final files = await msgDir.list().toList();
  if (files.isEmpty) return null;

  // Return the first (and typically only) file in the directory
  return files.first.path;
}