isText property

bool get isText

Implementation

bool get isText {
  final type = mimeType?.toLowerCase();
  if (type != null) {
    if (type.startsWith('text/')) return true;
    if (const <String>{
      'application/json',
      'application/javascript',
      'application/toml',
      'application/xml',
      'application/x-yaml',
      'application/yaml',
    }.contains(type)) {
      return true;
    }
  }

  final lowerName = name.toLowerCase();
  return const <String>[
    '.c',
    '.cc',
    '.cpp',
    '.css',
    '.csv',
    '.dart',
    '.go',
    '.h',
    '.html',
    '.java',
    '.js',
    '.json',
    '.kt',
    '.log',
    '.md',
    '.php',
    '.py',
    '.rb',
    '.rs',
    '.sh',
    '.sql',
    '.swift',
    '.toml',
    '.ts',
    '.txt',
    '.xml',
    '.yaml',
    '.yml',
    '.zsh',
  ].any(lowerName.endsWith);
}