to method

  1. @override
Future<T?> to(
  1. Widget page(), {
  2. bool? opaque,
  3. Transition? transition,
  4. Curve? curve,
  5. Duration? duration,
  6. String? id,
  7. String? routeName,
  8. bool fullscreenDialog = false,
  9. Object? arguments,
  10. List<BindingsInterface> bindings = const <BindingsInterface>[],
  11. bool preventDuplicates = true,
  12. bool? popGesture,
  13. bool showCupertinoParallax = true,
  14. double gestureWidth(
    1. BuildContext context
    )?,
  15. bool rebuildStack = true,
  16. PreventDuplicateHandlingMode preventDuplicateHandlingMode = PreventDuplicateHandlingMode.reorderRoutes,
})
override

Navigates to a new page and returns a result of type T.

Implementation

@override
Future<T?> to(
  Widget Function() page, {
  bool? opaque,
  Transition? transition,
  Curve? curve,
  Duration? duration,
  String? id,
  String? routeName,
  bool fullscreenDialog = false,
  Object? arguments,
  List<BindingsInterface> bindings = const <BindingsInterface>[],
  bool preventDuplicates = true,
  bool? popGesture,
  bool showCupertinoParallax = true,
  double Function(BuildContext context)? gestureWidth,
  bool rebuildStack = true,
  PreventDuplicateHandlingMode preventDuplicateHandlingMode =
      PreventDuplicateHandlingMode.reorderRoutes,
}) async {
  routeName = cleanRouteName("/${page.runtimeType}");

  final GetPage<T> getPage = GetPage<T>(
    name: routeName,
    opaque: opaque ?? true,
    page: page,
    gestureWidth: gestureWidth,
    showCupertinoParallax: showCupertinoParallax,
    popGesture: popGesture ?? Get.defaultPopGesture,
    transition: transition ?? Get.defaultTransition,
    curve: curve ?? Get.defaultTransitionCurve,
    fullscreenDialog: fullscreenDialog,
    bindings: bindings,
    transitionDuration: duration ?? Get.defaultTransitionDuration,
    preventDuplicateHandlingMode: preventDuplicateHandlingMode,
  );

  _routeTree.addRoute(getPage);
  final PageSettings args = _buildPageSettings(routeName, arguments);
  final RouteDecoder? route = _getRouteDecoder(args);
  final T? result = await _push(
    route!,
    rebuildStack: rebuildStack,
  );
  _routeTree.removeRoute(getPage);
  return result;
}