iconData static method

IconData iconData(
  1. String filename
)

Retrieves the appropriate icon for the given filename.

Parameters:

  • filename: The name of the file for which the icon is to be retrieved.

Returns:

  • The IconData representing the icon for the file.

Implementation

static IconData iconData(String filename) {
  if (filename.endsWith(".pdf")) {
    return CarbonIcons.pdf;
  }
  if (filename.endsWith("doc") || filename.endsWith("docx")) {
    return CarbonIcons.doc;
  }
  if (filename.endsWith("ppt") || filename.endsWith("pptx")) {
    return CarbonIcons.ppt;
  }
  if (filename.endsWith("xls") || filename.endsWith("xlsx")) {
    return CarbonIcons.xls;
  }
  if (filename.endsWith("zip")) {
    return CarbonIcons.zip;
  }
  if (filename.endsWith("txt")) {
    return CarbonIcons.txt;
  }
  if (filename.endsWith("jpg") ||
      filename.endsWith("jpeg") ||
      filename.endsWith("png") ||
      filename.endsWith("gif") ||
      filename.endsWith("bmp") ||
      filename.endsWith("webp")) {
    return CarbonIcons.image;
  }
  return Icons.attachment;
}