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
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.
Works with
Packages commonly used together with mime_type: ones it builds on, ones built on it, and its own family.
- livekit_clientBuilt on mime_typeFlutter Client SDK for LiveKit to build real-time video, audio, and data features.
- shelf_plusBuilt on mime_typeQuality of life addon for server-side development within the Shelf platform.
- alfredBuilt on mime_typeA performant, Express.js-like web server and REST API framework for Dart.
- gravix_rtcBuilt on mime_typeReal-time video and audio rooms for Flutter on Gravix Cloud.
- flutter_to_debianBuilt on mime_typeCLI tool to package Flutter Linux release builds into Debian (.deb) packages