Skip to content
pubscout

spanner

1.0.6, released a year ago by yaroo.dev

Generic HTTP router implementation using a Radix Tree for routing, params, and wildcards.

WASM-ready
$ flutter pub add spanner
Source repository

What it does

Spanner is a generic HTTP router that uses an internal Radix Tree (compact Prefix Tree) to manage and lookup routes efficiently. It supports route parameters, wildcards, middleware, and multiple HTTP methods.

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

Use it when

  • You need to build a custom HTTP server or backend router in Dart.
  • You require fast route lookups using a Radix Tree structure.
  • You need advanced routing capabilities like parameters and wildcards.

Skip it when

  • You are looking for mobile screen navigation or deep linking.
  • You want a batteries-included high-level web framework instead of just a router.

Strengths

  • Fast route lookup and insertion via a Radix Tree.
  • Supports route parameters and wildcards.
  • Decoupled from specific server frameworks.

Weaknesses

  • Minimal documentation beyond basic tests and examples.
  • Not intended for UI-level routing or navigation.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
2

Not documented

import 'package:spanner/spanner.dart';
import 'package:test/test.dart';

void main() {
  final router = Spanner()
    ..addRoute(HTTPMethod.GET, '/user/<userId>', 123);

  var result = router.lookup(HTTPMethod.GET, '/user/24');
  print(result?.params); // {'userId': '24'}
}

Alternatives

Packages that do the same job and could replace spanner.

  • shelf_router

    If you are building Dart backend servers using shelf and need standard request routing.