Skip to content
pubscout

mime

2.1.0, released 3 months ago by tools.dart.dev

Utilities to resolve MIME types from file names, magic bytes, and to parse multipart streams.

WASM-readyRock solid
$ flutter pub add mime
Source repository

What it does

Provides functions to look up a MIME type based on a filename or header bytes and to get a file extension from a MIME type. Includes a stream transformer that splits multipart/form-data into separate parts.

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

Use it when

  • You need to determine MIME types for files without external libraries
  • You need to parse multipart/form-data streams in a server or client
  • You want a lightweight, pure‑Dart solution for MIME handling

Skip it when

  • You require a full‑featured HTTP client that already handles multipart parsing
  • You need advanced MIME type detection beyond extensions and basic magic numbers

Strengths

  • Zero dependencies, pure Dart
  • Supports both extension and magic‑byte lookup
  • Provides a ready‑to‑use multipart stream transformer

Weaknesses

  • Limited to the built‑in MIME table; not exhaustive for obscure types
  • No async API for large file scanning beyond header bytes

Setup

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

void main() {
  print(lookupMimeType('test.html')); // text/html
  print(lookupMimeType('test', headerBytes: [0xFF, 0xD8])); // image/jpeg
}

Alternatives

Packages that do the same job and could replace mime.

Works with

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