diff --git a/lib/src/widgets/navi_rail/yaru_navigation_page.dart b/lib/src/widgets/navi_rail/yaru_navigation_page.dart index 8d38c8263..d78fc9a19 100644 --- a/lib/src/widgets/navi_rail/yaru_navigation_page.dart +++ b/lib/src/widgets/navi_rail/yaru_navigation_page.dart @@ -27,6 +27,8 @@ class YaruNavigationPage extends StatefulWidget { this.controller, this.leading, this.trailing, + this.onGenerateRoute, + this.navigatorKey, }) : assert(initialIndex == null || controller == null), assert((length == null) != (controller == null)); @@ -60,6 +62,12 @@ class YaruNavigationPage extends StatefulWidget { /// The trailing widget in the rail that is placed below the destinations. final Widget? trailing; + /// Called to generate a route for a given [RouteSettings]. + final RouteFactory? onGenerateRoute; + + /// A key to use when building the [Navigator] widget. + final GlobalKey? navigatorKey; + @override State createState() => _YaruNavigationPageState(); } @@ -67,12 +75,13 @@ class YaruNavigationPage extends StatefulWidget { class _YaruNavigationPageState extends State { late final ScrollController _scrollController; late YaruPageController _pageController; - final _navigatorKey = GlobalKey(); + late final GlobalKey _navigatorKey; @override void initState() { super.initState(); _scrollController = ScrollController(); + _navigatorKey = widget.navigatorKey ?? GlobalKey(); _updatePageController(); } @@ -182,6 +191,7 @@ class _YaruNavigationPageState extends State { : widget.pageBuilder(context, 0), ), ], + onGenerateRoute: widget.onGenerateRoute, onPopPage: (route, result) => route.didPop(result), observers: [HeroController()], ),