class FileExtension { static const String PDF = 'pdf'; static const String DOC = 'doc'; static const String DOCX = 'docx'; static const String XLS = 'xls'; static const String XLSX = 'xlsx'; static const String PPT = 'ppt'; static const String PPTX = 'pptx'; static const String TXT = 'txt'; static const String RTF = 'rtf'; // file extension icon constants static const String FILE_EXTENSION_PDF_ICON = 'assets/icons/file_extension/pdf.png'; static const String FILE_EXTENSION_DOC_ICON = 'assets/icons/file_extension/doc.png'; static const String FILE_EXTENSION_DOCX_ICON = 'assets/icons/file_extension/docx.png'; static const String FILE_EXTENSION_XLS_ICON = 'assets/icons/file_extension/xls.png'; static const String FILE_EXTENSION_XLSX_ICON = 'assets/icons/file_extension/xlsx.png'; static const String FILE_EXTENSION_PPT_ICON = 'assets/icons/file_extension/ppt.png'; static const String FILE_EXTENSION_PPTX_ICON = 'assets/icons/file_extension/pptx.png'; static const String FILE_EXTENSION_TXT_ICON = 'assets/icons/file_extension/txt.png'; static const String FILE_EXTENSION_RTF_ICON = 'assets/icons/file_extension/rtf.png'; static const List<String> SUPPORTED_FILE_EXTENSIONS = [ PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, TXT, RTF, ]; static const Map<String, String> FILE_EXTENSION_ICON_MAP = { PDF: FILE_EXTENSION_PDF_ICON, DOC: FILE_EXTENSION_DOC_ICON, DOCX: FILE_EXTENSION_DOCX_ICON, XLS: FILE_EXTENSION_XLS_ICON, XLSX: FILE_EXTENSION_XLSX_ICON, PPT: FILE_EXTENSION_PPT_ICON, PPTX: FILE_EXTENSION_PPTX_ICON, TXT: FILE_EXTENSION_TXT_ICON, RTF: FILE_EXTENSION_RTF_ICON, }; // get file extension icon static String? getFileExtensionIcon(String fileExtension) { if (FILE_EXTENSION_ICON_MAP.containsKey(fileExtension)) { return FILE_EXTENSION_ICON_MAP[fileExtension]; } return ''; } }
Flutter 文件类型常量
32 min read