Line data Source code
1 : import 'package:collection/collection.dart'; 2 : import 'package:quiver/core.dart'; 3 : import 'query_parser.dart'; 4 : import 'trie_router/trie_router.dart'; 5 : 6 : /// Information generated from a specific path (URL). 7 : /// 8 : /// This object has value equality - objects are equal if the path, 9 : /// queryParameters and pathParameters all match. 10 : class RouteInfo { 11 : /// The full path that generated this route. 12 : final String path; 13 : 14 : /// Query parameters from the path. 15 : /// 16 : /// e.g. a route template of /profile:id and a path of /profile/1 17 : /// becomes `pathParameters['id'] == '1'`. 18 : /// 19 : final Map<String, String> pathParameters; 20 : 21 : /// Query parameters from the path. 22 : /// 23 : /// e.g. /page?hello=world becomes `queryParameters['hello'] == 'world'`. 24 : /// 25 : final Map<String, String> queryParameters; 26 : 27 11 : RouteInfo.fromRouterResult(RouterResult result, this.path) 28 11 : : pathParameters = result.pathParameters, 29 11 : queryParameters = QueryParser.parseQueryParameters(path); 30 : 31 6 : RouteInfo(this.path, [this.pathParameters = const {}]) 32 6 : : queryParameters = QueryParser.parseQueryParameters(path); 33 : 34 7 : @override 35 : bool operator ==(Object other) => 36 7 : other is RouteInfo && 37 21 : path == other.path && 38 28 : DeepCollectionEquality().equals(pathParameters, other.pathParameters) && 39 28 : DeepCollectionEquality().equals(queryParameters, other.queryParameters); 40 : 41 3 : @override 42 3 : int get hashCode => hash3( 43 3 : path, 44 9 : DeepCollectionEquality().hash(pathParameters), 45 9 : DeepCollectionEquality().hash(queryParameters), 46 : ); 47 : 48 1 : @override 49 2 : String toString() => "RouteInfo: '$path'"; 50 : }