iconData static method
Retrieves the appropriate icon for the given filename based on its extension.
Returns a Carbon icon for recognized file types, or a generic attachment icon for unrecognized types.
Supported file types with specific icons:
- PDF files:
CarbonIcons.pdf - Word documents:
CarbonIcons.doc - PowerPoint presentations:
CarbonIcons.ppt - Excel spreadsheets:
CarbonIcons.xls - ZIP archives:
CarbonIcons.zip - Text files:
CarbonIcons.txt - Image files:
CarbonIcons.image - Other files:
Icons.attachment(generic)
Parameters:
filename: The filename to get an icon for
Returns the appropriate IconData for the file type.
Implementation
static IconData iconData(String filename) {
if (_hasExtension(filename, ['pdf'])) {
return CarbonIcons.pdf;
}
if (_hasExtension(filename, ['doc', 'docx'])) {
return CarbonIcons.doc;
}
if (_hasExtension(filename, ['ppt', 'pptx'])) {
return CarbonIcons.ppt;
}
if (_hasExtension(filename, ['xls', 'xlsx'])) {
return CarbonIcons.xls;
}
if (_hasExtension(filename, ['zip'])) {
return CarbonIcons.zip;
}
if (_hasExtension(filename, ['txt'])) {
return CarbonIcons.txt;
}
if (_hasExtension(filename, ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'])) {
return CarbonIcons.image;
}
return Icons.attachment;
}