Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose YaruNavigationPage.navigatorKey and onGenerateRoute #730

Merged
merged 2 commits into from Jul 4, 2023

Conversation

jpnurmi
Copy link
Member

@jpnurmi jpnurmi commented Jul 4, 2023

Allows pushing (named) routes onto YaruNavigationPage's internal Navigator. For example:

YaruNavigationPage(
  navigatorKey: _navigatorKey,
  ...
  onGenerateRoute: (settings) => switch (settings.name) {
    '/detail' => MaterialPageRoute(
        settings: settings,
        builder: (_) => DetailPage(settings.arguments as Detail),
      ),
    '/search' => MaterialPageRoute(
        settings: settings,
        builder: (_) => SearchPage(query: settings.arguments as String),
      ),
    _ => null,
  },
)

From within the navigation page:

Navigator.pushNamed(context, '/detail', arguments: detail);

From anywhere else such as a global search bar:

_navigatorKey.currentState!.pushNamed('/search', arguments: query);

Copy link
Member

@d-loose d-loose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jpnurmi jpnurmi merged commit dc9af5c into main Jul 4, 2023
9 checks passed
@jpnurmi jpnurmi deleted the navigation branch July 4, 2023 12:46
@github-actions github-actions bot mentioned this pull request Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants