routeIf function

dynamic routeIf(
  1. bool condition,
  2. dynamic routeName, {
  3. dynamic data,
  4. Map<String, dynamic>? queryParameters,
  5. NavigationType navigationType = NavigationType.push,
  6. dynamic result,
  7. bool removeUntilPredicate(
    1. Route route
    )?,
  8. PageTransitionSettings? pageTransitionSettings,
  9. PageTransitionType? pageTransition,
  10. dynamic onPop(
    1. dynamic value
    )?,
})

Navigate to a new route if a condition is met. If the condition is false, the route will not be navigated to.

Implementation

routeIf(bool condition, dynamic routeName,
    {dynamic data,
    Map<String, dynamic>? queryParameters,
    NavigationType navigationType = NavigationType.push,
    dynamic result,
    bool Function(Route<dynamic> route)? removeUntilPredicate,
    PageTransitionSettings? pageTransitionSettings,
    PageTransitionType? pageTransition,
    Function(dynamic value)? onPop}) async {
  if (!condition) return;
  await routeTo(routeName,
      data: data,
      queryParameters: queryParameters,
      navigationType: navigationType,
      result: result,
      removeUntilPredicate: removeUntilPredicate,
      pageTransitionSettings: pageTransitionSettings,
      pageTransitionType: pageTransition,
      onPop: onPop);
}