NavigationUtils class

Navigation helpers shared by ContextNavigationExtensions and MultilevelNavigatorExtensions — takes a GoRouter directly for flexibility.

Constructors

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
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

calculateTargetPathForPop({required String currentPath, required int? level, required int? levelFromRouteName, required int pathDepth}) → String?
clearAllFeaturePaths(NavigationStorage storage) → void
clearFeaturePath(NavigationStorage storage, String featureKey) → void
closeAllModals(GoRouter router) → void
closeModal(GoRouter router, String modalId) → void
Removes modalId from the modal query parameter, dropping the parameter entirely if it was the last one open.
closeModalAsync(GoRouter router, String modalId) → Future<void>
closeModalInUri(Uri currentUri, String modalId) → Uri
closeModalWithResult<T>(GoRouter router, NavigationStorage storage, String modalId, T? result) → void
completeModalWithNull(NavigationStorage storage, String modalId) → void
completeModalWithResult<T>(NavigationStorage storage, String modalId, T? result) → void
Completes the modal's Completer without closing it — used internally by MultilevelModalOverlay.
getCurrentExtra(GoRouter router) → Object?
getCurrentFragment(GoRouter router) → String
getCurrentQueryParameters(GoRouter router) → Map<String, String>
getFeaturePath(NavigationStorage storage, String featureKey) → String?
getModalArgs<T>(NavigationStorage storage, String modalId) → T?
go(GoRouter router, String location, {Map<String, String> queryParameters = const <String, String>{}, Object? extra}) → void
Accepts query parameters both in location and in queryParameters; the latter take precedence on key collision.
goNamed(GoRouter router, String name, {Map<String, String> pathParameters = const <String, String>{}, Map<String, String> queryParameters = const <String, String>{}, List<String> toggleModals = const <String>[], Object? extra}) → void
If modal isn't explicitly in queryParameters, it's dropped from the current query params (so a modal can be closed by navigating away without re-specifying it). toggleModals toggles each id: closes it if currently open, opens it otherwise.
goNamedWithCloseModal(GoRouter router, String name, {required List<String> modalIds, Map<String, String> pathParameters = const <String, String>{}, Map<String, String> queryParameters = const <String, String>{}, Object? extra}) → void
Closes modalIds and navigates to name as a single atomic step.
goNamedWithModal(GoRouter router, String name, {required String modalId, Map<String, String> pathParameters = const <String, String>{}, Object? extra}) → void
goNamedWithOpenModal(GoRouter router, String name, {required String modalId, Map<String, String> pathParameters = const <String, String>{}, Object? extra}) → void
Opens modalId on the current URI, then navigates to name keeping that modal plus any others already open (comma-joined).
goWithModal(GoRouter router, String location, {required String modalId, Object? extra}) → void
See goNamedWithOpenModal, for a path instead of a route name.
isModalOpen(GoRouter router, String modalId) → bool
mergeQueryParametersForGo({required Map<String, String> currentQueryParams, required Map<String, String> locationQueryParams, required Map<String, String> newQueryParams}) → Map<String, String>
Merges, in increasing priority: current query params (minus modal, same as goNamed so go() can close a modal on navigation), params parsed from the location string, then newQueryParams.
mergeQueryParametersForGoNamed({required Map<String, String> currentQueryParams, required Map<String, String> newQueryParams, required List<String> toggleModals, required Uri currentUri}) → Map<String, String>
mergeQueryParametersForPushNamed({required Map<String, String> currentQueryParams, required Map<String, String> newQueryParams}) → Map<String, String>
openModal(GoRouter router, String modalId) → void
Adds modalId to the modal query parameter, comma-joined with any modals already open.
openModalAsync<T>(GoRouter router, NavigationStorage storage, String modalId) → Future<T?>
Opens modalId and returns a Future that completes with whatever closeModalWithResult passes when the modal closes (null otherwise).
openModalAsyncWithArgs<T>(GoRouter router, NavigationStorage storage, String modalId, dynamic args) → Future<T?>
Like openModalWithArgs, but returns a Future with the close result.
openModalInUri(Uri currentUri, String modalId) → Uri
openModalWithArgs(GoRouter router, NavigationStorage storage, String modalId, dynamic args) → void
Stores args in NavigationStorage and opens the modal; readable via getModalArgs, cleared automatically when the modal closes.
pop(GoRouter router, {int? level, List<FeatureNavigationConfiguration>? allFeatures}) → void
Closes level and everything above it. If level is omitted, it's resolved from the current route name (via allFeatures) or, failing that, from the path depth.
pushNamed(GoRouter router, String name, {Map<String, String> pathParameters = const <String, String>{}, Map<String, String> queryParameters = const <String, String>{}, Object? extra}) → void
removeModalFromUri(Uri currentUri) → Uri
switchToFeature(GoRouter router, NavigationStorage storage, {required String featureKey, required String defaultPath, String? currentFeatureKey}) → void
Switches to featureKey, saving the current URI under currentFeatureKey (if given) and restoring featureKey's previously saved URI, or defaultPath if it has none.
toggleModals(GoRouter router, List<String> modalIds) → void
Toggles each id in modalIds: closes it if open, opens it otherwise.
toggleModalsInUri(Uri currentUri, List<String> modalIds) → Uri