NavigationService class

Navigation service for managing app navigation

Inheritance

Constructors

factory

Properties

currentRoute String?
Gets the current route name
no setter
enableDebugMode bool
finalinherited
hashCode int
The hash code for this object.
no setterinherited
isInitialized bool
Gets whether this service has been initialized
no setterinherited
Gets the current navigator state
no setter
final
routes Map<String, WidgetBuilder>
Gets registered routes
no setter
routeStack List<String>
Gets the route stack
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addRouteGuard(String routeName, Future<bool> guard(Object?)) → void
Adds a route guard
allowNavigation() → void
Allows navigation
canGoBack() bool
Checks if navigation can go back
createRouteObserver() RouteObserver<PageRoute>
Creates a route observer to track route changes
dispose() Future<void>
Disposes of the service and cleans up resources
inherited
goBack<T>([T? result]) → void
Goes back to the previous route
initialize(Map<String, dynamic> config) Future<void>
Initializes the service with the provided configuration
inherited
Navigates to a named route
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDispose() Future<void>
Override this method to implement service-specific cleanup
override
onInitialize(Map<String, dynamic> config) Future<void>
Override this method to implement service-specific initialization
override
popUntil(String routeName) → void
Pops routes until a specific route is reached
preventNavigation() → void
Prevents navigation temporarily
registerRoute(String name, WidgetBuilder builder) → void
Registers a route
registerRoutes(Map<String, WidgetBuilder> routes) → void
Registers multiple routes
removeRouteGuard(String routeName) → void
Removes a route guard
showBottomSheet<T>({required WidgetBuilder builder, Color? backgroundColor, double? elevation, ShapeBorder? shape, Clip? clipBehavior, BoxConstraints? constraints, bool? enableDrag, bool isDismissible = true, bool isScrollControlled = false, bool useRootNavigator = false, RouteSettings? routeSettings}) Future<T?>
Shows a bottom sheet
showDialogModal<T>({required WidgetBuilder builder, bool barrierDismissible = true, Color? barrierColor, String? barrierLabel, bool useSafeArea = true, bool useRootNavigator = true, RouteSettings? routeSettings}) Future<T?>
Shows a dialog
showSnackBar({required String message, Duration duration = const Duration(seconds: 4), SnackBarAction? action, Color? backgroundColor, double? elevation, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? padding, ShapeBorder? shape, SnackBarBehavior? behavior, double? width}) → void
Shows a snackbar
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

instance NavigationService
no setter

Static Methods

resetInstance() → void
Reset singleton instance (for testing only)