Skip to content
pubscout

mime_type

1.0.1, released 2 years ago by an unverified publisher

Library to map file names or extensions to MIME types and vice versa

WASM-ready
$ flutter pub add mime_type
Source repository

What it does

Provides three helper functions: mime, mimeFromExtension, and extensionFromMime. It is useful for setting Content-Type headers in HTTP servers and for determining file extensions from MIME types.

AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to set the correct Content-Type header when serving files over HTTP
  • You need to determine a file extension from a MIME type in a server or CLI tool

Skip it when

  • You need a full HTTP client or server framework; this package only handles MIME type mapping
  • You require advanced media type handling beyond simple mapping

Strengths

  • Simple API, no dependencies, null-safe
  • Supports a wide range of MIME types, including recent additions like mjs and woff2
  • Fast hashmap lookup
  • MIT license

Weaknesses

  • No support for content negotiation or media type parameters
  • Limited to MIME type mapping only

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:mime_type/mime_type.dart';

String mimeType = mime('image.png');
String ext = extensionFromMime('image/png');

Alternatives

Packages that do the same job and could replace mime_type.

  • http

    Provides a full HTTP client/server stack, including MIME type handling via its own utilities

  • dio

    Offers advanced HTTP client features with built-in content-type handling

Works with

Packages commonly used together with mime_type: ones it builds on, ones built on it, and its own family.