@@ -26,7 +26,8 @@ class RoutingKitRoutingService<T, Config extends Object>
2626
2727 RouteContext ? _context;
2828
29- final Map <Uri , (Future <bool >, LeafRoute <T , Config >)> _pendingNavigations = {};
29+ final Map <Uri , (Future <bool >, LeafRoute <T , Config >, RouteContext )>
30+ _pendingNavigations = {};
3031
3132 /// The root module of the application.
3233 final RootModule <T , Config > rootModule;
@@ -250,6 +251,16 @@ class RoutingKitRoutingService<T, Config extends Object>
250251 return Uri .parse (normalized).pathSegments;
251252 }
252253
254+ RouteContext _createContext (Uri uri, Map <String , String > pathParams) {
255+ return RouteContext (
256+ fullPath: uri.toString (),
257+ pathParams: pathParams,
258+ queryParams: uri.queryParameters,
259+ queryParamsAll: uri.queryParametersAll,
260+ fragment: uri.fragment,
261+ );
262+ }
263+
253264 @override
254265 Future <void > navigate (
255266 String path, {
@@ -283,10 +294,10 @@ class RoutingKitRoutingService<T, Config extends Object>
283294 if (_pendingNavigations.containsKey (uri)) {
284295 log ('Navigation to $path is already in progress, forwarding callback.' );
285296
286- final (future, leaf) = _pendingNavigations[uri]! ;
297+ final (future, leaf, context ) = _pendingNavigations[uri]! ;
287298
288299 if (! skipPreview) {
289- callback (leaf.view.preview (RouteContext . fromUri (uri) ), true );
300+ callback (leaf.view.preview (context ), true );
290301 }
291302
292303 log ('Waiting for pending navigation to $path to complete.' );
@@ -302,7 +313,7 @@ class RoutingKitRoutingService<T, Config extends Object>
302313
303314 log ('Pending navigation to $path completed, invoking content callback.' );
304315
305- callback (await leaf.view.content (RouteContext . fromUri (uri) ), false );
316+ callback (await leaf.view.content (context ), false );
306317
307318 return ;
308319 }
@@ -346,10 +357,11 @@ class RoutingKitRoutingService<T, Config extends Object>
346357 }
347358
348359 final (: leaf, : lineage) = _resolveLeafRoute (matchedRoute, path);
360+ final context = _createContext (uri, match.params);
349361
350- final future = _navigate (uri , leaf, lineage, skipPreview, handler);
362+ final future = _navigate (context , leaf, lineage, skipPreview, handler);
351363
352- _pendingNavigations[uri] = (future, leaf);
364+ _pendingNavigations[uri] = (future, leaf, context );
353365 _currentNavigation = future;
354366 await future;
355367 } catch (e, s) {
@@ -361,15 +373,15 @@ class RoutingKitRoutingService<T, Config extends Object>
361373 }
362374
363375 Future <bool > _navigate (
364- Uri uri ,
376+ RouteContext initialContext ,
365377 LeafRoute <T , Config > leaf,
366378 List <Route <T , Config >> lineage,
367379 bool skipPreview,
368380 void Function (T , bool ) callback,
369381 ) async {
370- var context = RouteContext . fromUri (uri) ;
382+ var context = initialContext ;
371383 final previousContext = _context;
372- final cleanPath = uri.path;
384+ final cleanPath = context. uri.path;
373385 final middleware = _collectMiddleware (lineage);
374386
375387 log ('Navigating to $cleanPath with context: $context ' );
0 commit comments