Segment<T>.param constructor

Segment<T>.param({
  1. required ParamParser parser,
  2. RouteBuilder<T>? create,
  3. List<Segment<T>> children,
  4. RouteBuilder<T>? createError,
})

Creates a Segment that matches a path segment using the parser and injects it into the ParseContext. Usually used with a UintParser.

  /// Matches '/users/{id}', where {id} is any non-negative integer as defined
  /// by [UintParser].
  Segment.param(
    parser: const UintParser('id'),
    create: (context) => context['id'] as String,
  ),

See also:

Implementation

factory Segment.param({
  required ParamParser parser,
  RouteBuilder<T>? create,
  List<Segment<T>> children,
  RouteBuilder<T>? createError,
}) = ParamSegment<T>;