getAllowedFileBrowserTypes function

Set<String> getAllowedFileBrowserTypes(
  1. {required bool useLiveMediaOnly,
  2. required Set<String> allowedFileTypes}
)

it gives us a allowed file types If useLiveMediaOnly is true then we remove all media (images & videos) types from allowedFileTypes set of strings If useLiveMediaOnly is false then we return allowedFileTypes as it is.

Implementation

Set<String> getAllowedFileBrowserTypes({required bool useLiveMediaOnly, required Set<String> allowedFileTypes}) {
  if (useLiveMediaOnly) {
    final allowedFileBrowserTypes = Set<String>.from(allowedFileTypes)
      //remove all image file type
      ..removeWhere(
        (element) => {
          'apng',
          'avif',
          'gif',
          'jpg',
          'jpeg',
          'jfif',
          'pjpeg',
          'pjp',
          'png',
          'svg',
          'webp',
          'bmp',
          'ico',
          'cur',
          'tif',
          'tiff',
          'heif',
        }.contains(element),
      )
      //remove all video file type
      ..removeWhere(
        (element) => {
          'mp4',
          'mov',
          'm4v',
          'hevc',
          '3gp',
          'mkv',
          'ts',
          'webm',
        }.contains(element),
      );
    return allowedFileBrowserTypes;
  }
  return allowedFileTypes;
}