LinkHandler class abstract

Class describing parser for link and mapping to route

Example:

class PostLinkHandler extends BottomSheetLinkHandler {
  @override
  Future<UIRoute> parseLinkToRoute(String url) async {
    final uriPath = Uri.parse(url);
    final segments = uriPath.pathSegments;
    final queryParams = uriPath.queryParametersAll;

    final patternUriPath = Uri.parse('posts/:{id}');
    final patternQuery = [
      'filter',
    ];
    final patternSegments = patternUriPath.pathSegments;

    Map<String, dynamic> queryParamsForView = {};
    Map<String, dynamic> pathParams = {};

    for (var index = 0; index < patternSegments.length; index++) {
      final pathSegmentPattern = patternSegments[index];

      if (pathSegmentPattern == ':{id}') {
        pathParams['id'] = segments[index];
      }
    }

    for (var index = 0; index < patternQuery.length; index++) {
      final queryParam = patternQuery[index];

      queryParamsForView['filter'] = queryParams[queryParam] ?? [];
    }

    final route = app.navigation.bottomSheets.post(
      pathParams: pathParams,
      queryParams: queryParamsForView,
    );

    return route;
  }
}
Implementers

Constructors

LinkHandler.new()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parseLinkToRoute(String url) Future<UIRoute?>
Maps given url to navigation UIRoute if you want to skip this url return null
processRoute(UIRoute route) Future<void>
Opens constructed route
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited