contentTypeForExtension method

ContentType? contentTypeForExtension(
  1. String extension

Returns a ContentType for a file extension.

Returns the associated content type for extension, if one exists. Extension may have leading '.', e.g. both '.jpg' and 'jpg' are valid inputs to this method.

Returns null if there is no entry for extension. Entries can be added with setContentTypeForExtension.


ContentType? contentTypeForExtension(String extension) {
  if (extension.startsWith(".")) {
    return _extensionMap[extension.substring(1)]!;
  return _extensionMap[extension]!;