createRoute method

  1. @override
Route<T> createRoute(
  1. BuildContext context
)
override

Creates the Route that corresponds to this page.

The created Route must have its Route.settings property set to this Page.

Implementation

@override
Route<T> createRoute(BuildContext context) {
  // Read off the route's CURRENT page, not this one: when the router updates
  // the page in place (same key, new child: a changed query parameter), the
  // route keeps its object and rebuilds with the new one.
  Widget current(BuildContext sheetContext) {
    final page = ModalRoute.of(sheetContext)?.settings;
    final shown = page is LedgerSheetPage ? page.child : child;
    return back ? _BackExit(child: shown) : shown;
  }

  if (fullScreen) {
    return MaterialPageRoute<T>(
      settings: this,
      fullscreenDialog: true,
      builder: (sheetContext) => RoutePresentationScope(
        presentation: RoutePresentation.sheet,
        child: ColoredBox(
          color: sheetContext.ledgerTheme.background,
          child: current(sheetContext),
        ),
      ),
    );
  }
  return LedgerSheet.pageRoute<T>(
    context: context,
    settings: this,
    drawer: drawer,
    confirm: confirm,
    builder: current,
  );
}