go_navigator 2.0.3 go_navigator: ^2.0.3 copied to clipboard
Go navogator handles navigation by reducing class argument and exposing the top most route args to the context and navigation key where passed
# GoNavigator - 2.0.3
A Flutter plugin providing advanced navigation utilities for managing routes and the navigation stack in a Flutter application.
## Features
- **Navigate to specified routes with optional arguments.**
- **Clear all previous routes from the stack.**
- **Replace the current route with a named route.**
- **Pop until a specific route is reached.**
- **Navigate back to the previous screen with provided data.**
- **Nested Routing**
- **Deeplink Support**
## Changes in Version 2.0.3
### Added
- **`GoNavigator` Class Enhancements:**
- Improved route handling with a more detailed and structured route definition.
- Support for nested routes, allowing a map of routes where values can be either widget constructors or nested maps of routes.
- Enhanced error handling to provide clearer information about route definition issues.
### Changed
- **Refactor `generateRoute` Method:**
- The method now recursively handles nested routes.
- Improved route builder lookup to support both leaf routes (directly associated with widget constructors) and nested routes (associated with nested maps).
- **Breaking Change:**
- The `routes` property now expects a map where values can be either a widget constructor or a nested map of routes.
```dart
GoNavigator goNavigator = GoNavigator(
initialRoute: const HomePage(),
routes: {
'/': (context, args) => HomePage(),
'home': (context, args) => HomePage(),
'dashboard': {
'/': (context, args) => DashboardPage(),
'settings': {
'/': (context, args) => SettingsPage(),
'profile': {
'/': (context, args) => ProfilePage(),
'edit': (context, args) {
return const EditProfilePage();
},
},
},
},
'profile': {
'/': (context, args) => ProfilePage(),
'edit': (context, args) {
return const EditProfilePage();
},
},
},
);
onGenerateRoute: goNavigator.generateRoute
Fixed #
- Bug Fix:
- Resolved the type error issue related to the return type of nested route builders.
- Ensured proper handling of both leaf routes and nested routes, making sure the returned value is a valid widget constructor.
Improved #
-
Documentation:
- Updated inline comments for better code readability and understanding.
- Detailed inline comments in the example application for each widget and method.
-
Validation:
- Enforced that the
routes
map must not be empty. An exception is thrown if theroutes
map is empty.
- Enforced that the
-
Error Handling:
- Improved error messages to provide clearer information about the issues related to route definitions.
Deprecated #
- Deprecation:
- Removed unnecessary null check for
initialRoute
as it is already checked in the constructor.
- Removed unnecessary null check for
Compatibility #
- Version Compatibility:
- Compatible with Flutter version 3.1.3 and above.
Changes in Version 2.0.3 #
Added #
Map
replacesMyRouteArguments
for more clarity and consistency.- Example Application: Added a complete example demonstrating the use of
GoNavigator
in a Flutter application.- Example includes:
- Navigation between multiple pages.
- Passing arguments between pages.
- Using
GlobalKey<NavigatorState>
for navigation. - Detailed inline comments for better understanding and readability.
- Example includes:
Changed #
-
Decentralized parameters for each function in the navigation system.
- Before:
Go(context).to(routeName: Page1.routeName)
- After:
context.to(Page1.routeName, args:{'name': 'Jesse'})
- Before:
-
Enhancement: Added support for nested routes in the
GoNavigator
class.- Updated the
generateRoute
method to recursively handle nested routes. - Allowed the route map to include both leaf routes (directly associated with widget constructors) and nested routes (associated with nested maps).
- Updated the
-
Breaking Change: The
routes
property now expects a map where the values can be either a widget constructor or a nested map of routes.GoNavigator goNavigator = GoNavigator( initialRoute: const Page1(), routes: { Page2.routeName: (context, args) => const Page2(), Page3.routeName: (context, args) => const Page3(), }, ); onGenerateRoute: goNavigator.generateRoute
-
Bug Fix: Resolved the type error issue related to the return type of nested route builders.
- Ensured proper handling of both leaf routes and nested routes, making sure the returned value is a valid widget constructor.
-
Documentation: Updated inline comments for better code readability and understanding.
- Detailed inline comments in the example application for each widget and method.
-
Deprecation: Removed unnecessary null check for
initialRoute
as it is already checked in the constructor. -
Validation: Enforced that the
routes
map must not be empty. An exception is thrown if theroutes
map is empty. -
Error Handling: Improved error messages to provide clearer information about the issues related to route definitions.
-
Version Compatibility: Compatible with Flutter version 3.1.3 and above.
Version 1.0.1 (Original Implementation) #
-
Feature: Introduced the
GoNavigator
class for building and managing routes in a Flutter application. -
Basic Routing: Supported basic routing with an initial route and a map of named routes associated with widget constructors.
-
Error Handling: Threw an exception if the
routes
map was empty, ensuring that a valid route configuration is provided. -
Documentation: Included inline comments for method explanations and usage.
-
Version Compatibility: Compatible with Flutter version 4.0.0
These methods simplify navigation tasks and provide an easy way to manage route navigation in your Flutter app.
Getting Started #
To use this navigation system in your Flutter app:
- Add the
go_navigator
plugin to yourpubspec.yaml
file. - Import the package into your Dart code.
- Create an instance of the
Go<T>
class and use its methods for navigation tasks.
For detailed implementation and usage instructions, refer to the code documentation and examples provided.
Platform Support #
This plugin is available on Android, iOS, MacOS, and Windows.
For more detailed instructions on how to use and implement this plugin, refer to Flutter's documentation.