playx_navigation 2.1.0
playx_navigation: ^2.1.0 copied to clipboard
Playx Navigation is a Flutter package that enhances app navigation with advanced features like route lifecycle management, custom transitions, and flexible configuration.
Changelog #
2.1.0 #
New Features #
- Init-aware builder (
initBuilder): Added an optionalinitBuilderparameter toPlayxRouteandPlayxShellBranchthat receives(context, state, isInitialized). When provided, the user has full control over what to render based on the binding's initialization state. The existingbuilderwith(context, state)signature remains unchanged — the library continues to manage loading/content switching automatically.// Standard builder — library manages loading (unchanged from 1.0.0): PlayxRoute( path: '/products', builder: (context, state) => ProductsPage(), binding: ProductsBinding(), ) // Init-aware builder — user handles everything: PlayxRoute( path: '/profile', initBuilder: (context, state, isInitialized) { if (!isInitialized) return ProfileSkeleton(); return ProfilePage(); }, binding: ProfileBinding(), ) - Shell Builder: Added
shellBuilderparameter toPlayxRoute,PlayxShellBranch, andPlayxPageConfig. The shell (AppBar, Drawer, Scaffold) renders immediately during navigation transitions, preventing blank frames. Only the body content waits for the binding'sonEnterto complete. Only applies when usingbuilder, notinitBuilder.PlayxRoute( path: '/channels', builder: (context, state) => ChannelsListView(), shellBuilder: (context, state, isInitialized, child) => Scaffold( appBar: AppBar(title: Text('Channels')), drawer: MyDrawer(), body: child, ), binding: ChannelsBinding(), ) - Non-blocking initialization: Added
waitForBindingparameter toPlayxRoute,PlayxShellBranch, andPlayxPageConfig. When set tofalse, the page content renders immediately whileonEnterruns in the background. Only applies when usingbuilder. - Initialization transition animation: Added
initTransitionDurationparameter toPlayxRoute,PlayxShellBranch, andPlayxPageConfig. When set, anAnimatedSwitchercrossfade smoothly transitions from the loading widget to the page content. Only applies when usingbuilder. - Global page configuration via
PlayxPageConfig: Addedconfigparameter toPlayxNavigationBuilderto set global defaults forloadingWidget,waitForBinding,shellBuilder, andinitTransitionDuration. Individual routes can override any of these settings.PlayxNavigationBuilder( router: router, config: PlayxPageConfig( loadingWidget: Center(child: CircularProgressIndicator()), waitForBinding: true, initTransitionDuration: Duration(milliseconds: 300), ), builder: (context) => MyApp(), ) - New typedefs:
PlayxRouteWidgetBuilderandPlayxShellWidgetBuilderfor type-safe builder signatures.
Configuration Resolution #
Route-level parameter → Global PlayxPageConfig → Built-in default.
These settings only apply when using the standard builder, not initBuilder:
loadingWidget: Route > Global >SizedBox.shrink()waitForBinding: Route > Global >trueshellBuilder: Route > Global >nullinitTransitionDuration: Route > Global >null(no animation)
1.0.0 #
New Features #
- New
onInitAppLifecycle Method forPlayxBinding: Added a newonInitApp()lifecycle method that is called once during app initialization. This allows developers to register app-level instances (repositories, datasources, services) directly from their bindings before any route lifecycle events are triggered. PlayxNavigation.boot()now returns aFuture<void>and automatically discovers allPlayxBindinginstances in the route tree, callingonInitApp()on each during initialization.- New
ensureInitialized: A staticFuture<void>getter that completes whenboot()and allonInitApp()calls finish. Useful for gating startup logic (e.g., splash screens). - New
isInitialized: A staticboolgetter that returnstrueafterboot()has completed. - New
bindings: A static getter that returns an unmodifiable list of all discoveredPlayxBindinginstances from the route tree. - New
findBinding<T>(): Type-safe lookup to retrieve a specific binding by its concrete type. ThrowsStateErrorif not found. - New
findBindingOrNull<T>(): Same asfindBinding<T>()but returnsnullinstead of throwing if no match is found. - Custom Loading Widget: Added
loadingWidgetoption toPlayxRouteandPlayxShellBranch. This widget is displayed whileonEnteris being initialized, defaulting toSizedBox.shrink(). - Initialization Blocking: The route's child widget is only built after
onEntercompletes. This ensures dependencies registered inonEnter(e.g., GetX controllers) are available during the first build.
Lifecycle Refactoring (Breaking Changes) #
- Removed redirect hack: Binding lifecycle methods (
onEnter,onReEnter) are no longer triggered through GoRoute'sredirectcallback. Theredirectparameter onPlayxRouteis now passed through directly for user-defined redirection logic only. onEnteris now fired fromPlayxPage.initState: Guarantees it fires exactly once when the page widget mounts. This is more reliable than the previous redirect-based approach.onExitis now fired fromPlayxPage.dispose: Fires only when the page is truly removed from the widget tree. For shell routes, this meansonExitdoes NOT fire on branch switches (the widget stays alive), only when the route is actually removed.onHidden/onReEnterhandled by route-change listener: These fire when the top route changes — covering push (child covers parent), pop (child removed, parent revealed), and branch switching.wasPoppedAndReentereddetection improved: Now uses path-based comparison to distinguish between a child being popped (true) and a branch switch (false).- Removed
shouldExecuteOnExit: No longer needed sincePlayxPage.disposedirectly handlesonExit. PlayxNavigationBuilderupdated to handle the async boot process seamlessly.
0.3.0 #
- Update GoRouter to v17.0.0
0.2.0 #
- Update GoRouter to v16.0.0
- Update minimum Dart SDK version to 3.6.0 and Flutter SDK version to 3.27.0
- Refactored
PlayxRouteandPlayxNavigationBuilderto better handle route state and binding events. GoRouterStatenow passed correctly toonReEnter.
0.1.2 #
- Update GoRouter to v14.8.1
- Add
setupWebmethod forPlayxNavigationwhich allows for using path-based URLs and enables URL-based imperative APIs
0.1.0 0.1.1 #
New Features #
-
PlayxShellBranch:- Introduced the
PlayxShellBranchclass, an extension ofStatefulShellBranchfor creating branches with a single or multiple routes using[PlayxRoute].
- Introduced the
-
PlayxNavigation:- Added new
rootNavigatorKeyandnavigationContextgetters for enhanced navigation control. - Introduced a new
maybePopmethod in thePlayxNavigationclass for conditional navigation stack popping. - Added a new
goRoutergetter that returns theGoRouterinstance used for navigation. - Introduced a new
currentStategetter that retrieves the currentGoRouterStateobject representing the state of the navigation stack. - Updated
currentRouteto now returnGoRouteinstead ofRouteMatchas it is based on the current state. - Updated
currentRouteNameto now return the route name based on the current state.
- Added new
Dependency Updates #
- Upgraded the
go_routerpackage to version14.6.3.
Enhancements to PlayxBinding #
- Refactored Behavior:
-
onEnterandonExit:- Now triggered only when a route is entered or exited for the first time correctly.
-
onReEnter:- A new method that fires when a route is re-entered after being previously visited but not removed from the stack.
- Example scenarios:
- Switching between branches in a
StatefulShellBranchwhile the route remains in memory (wasPoppedAndReenteredisfalse). - Navigating back to a route after temporarily leaving it using
PlayxNavigation.toNamed, whereonHiddenis called beforeonReEnter(wasPoppedAndReenteredistrue).
- Switching between branches in a
-
onHidden:- A new method called when a route is hidden but not removed from the stack.
- Key use cases:
- Pausing tasks or releasing temporary resources when a route is no longer visible but remains in memory.
- Switching to another branch in a
StatefulShellBranchor navigating away while leaving the route active in the background.
- Sequence of calls:
- If the route is removed,
onExitis called afteronHidden. - If revisited,
onReEnteris called afteronHidden.
- If the route is removed,
-
0.0.1 #
- Initial release