iconData static method

IconData iconData(
  1. String filename
)

Retrieves the appropriate icon for the given filename.

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;
}