getMediaType function

MediaType getMediaType(
  1. String? mediaSrc
)

Implementation

MediaType getMediaType(String? mediaSrc) {
  if (isURL(mediaSrc, allowUnderscore: true)) {
    return MediaType.network;
  } else if (mediaSrc!.startsWith('assets')) {
    return MediaType.asset;
  } else {
    try {
      final uri = Uri.file(mediaSrc, windows: Platform.isWindows);
      if (uri.hasAbsolutePath) {
        return MediaType.file;
      }
      throw Exception('Invalid Media Type');
    } catch (e) {
      throw Exception('Invalid Media Type');
    }
  }
}