getFileIcon method

Widget getFileIcon(
  1. String extension,
  2. ColorScheme colorScheme
)

Implementation

Widget getFileIcon(String extension, ColorScheme colorScheme) {
  Color iconColor = Colors.grey;

  IconData iconData = switch (extension.toLowerCase()) {
    'pdf' => Icons.picture_as_pdf,
    'doc' || 'docx' => Icons.description,
    'xls' || 'xlsx' => Icons.table_chart,
    'ppt' || 'pptx' => Icons.slideshow,
    'jpg' || 'jpeg' || 'png' || 'gif' || 'bmp' || 'webp' => Icons.image,
    'mp4' || 'avi' || 'mov' || 'wmv' => Icons.video_file,
    'mp3' || 'wav' || 'aac' => Icons.audio_file,
    'zip' || 'rar' || '7z' => Icons.archive,
    'txt' => Icons.text_snippet,
    'json' => Icons.code,
    _ => Icons.insert_drive_file,
  };

  return Icon(
    iconData,
    size: 16.0,
    color: iconColor,
  );
}