Skip to content
pubscout

shelf_multipart

2.0.2, released 3 weeks ago by simonbinder.eu

Parses multipart and form-data requests for shelf handlers.

WASM-ready
$ flutter pub add shelf_multipart
Source repository

What it does

shelf_multipart provides extension types and methods for shelf handlers to easily check for and parse multipart and multipart/form-data requests. It allows iterating over parts, reading part headers, and reading data as streams, bytes, or strings.

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

Use it when

  • You are building a backend using the shelf package
  • You need to handle file uploads or multipart form data in Dart

Skip it when

  • You are not using the shelf package for your server
  • You only need to handle standard JSON or URL-encoded bodies

Strengths

  • Provides type safety around multipart checks using extension types
  • Easy iteration over request parts and form data parameters
  • Integrates seamlessly with the shelf ecosystem

Weaknesses

  • Limited to the shelf package ecosystem

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
4

not documented

Future<Response> myHandler(Request request) async {
  if (request.multipart() case var multipart?) {
    await for (final part in multipart.parts) {
      final headers = part.headers;
    }
  } else {
    return Response(401);
  }
}

Alternatives

Packages that do the same job and could replace shelf_multipart.

Works with

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