lukepighetti / fluro

Fluro is a Flutter routing library that adds flexible routing options like wildcards, named parameters and clear route definitions.
https://pub.dev/packages/fluro
MIT License
3.67k stars 417 forks source link

Add predicate parameters to the navigateTo method. #249

Open chan132 opened 3 years ago

chan132 commented 3 years ago

Two parameters [isPushAndRemove] and [predicate] have been added to [FluroRouter.navigateTo] so that users can customize [RoutePredicate].

e.g. Avoid opening the same page (the scenario is as follows: when multiple network requests fail, the reason is that the network disconnects and the network error page needs to be opened, but avoids repeated opening)

router.navigateTo(
  context,
  Routes.networkErrorPage,
  isPushAndRemove: true,
  predicate: (route) =>
      route.isCurrent && route.settings.name == Routes.networkErrorPage
          ? false
          : true,
);