Pages
Show a page over the others and go back, with Flutter's Navigator.
Pages are kept by Flutter's Navigator: Navigator::push(app, context, route) shows a page over the others, and Navigator::pop(app, context, result) goes back, push's future answering the result, an Option<Rc<dyn Any>>. A phone's Back gesture pops the top page automatically.
- WinUI:
FluentAppor the template'sWidgetsAppholds the pages, each aPageRouteBuilder, which shows its page with no animation. A window's main pages are usually aNavigationView's instead: the app shows the selected item's page as its content. - Cupertino:
CupertinoAppholds them, and aCupertinoPageRouteis a page that slides in from the right, its title what the next page's back button says. - Material:
MaterialAppholds them, and aMaterialPageRouteis a page that comes in as the platform's do.
// WinUI
let route = PageRouteBuilder::new(app, Rc::new(|_app, _context, _, _| Details.into_widget()));
Navigator::push(app, context, route.into_erased());
Navigator::pop(app, context, None); // in Details, back
// Cupertino
let page: WidgetBuilder = Rc::new(|_app, _context| CupertinoPageScaffold::new(Details).into_widget());
let route = CupertinoPageRoute::new(app, page).title(app, "Details".into());
Navigator::push(app, context, route.into_erased());Navigator::push takes a RouteRef, the kept handle of any route, which into_erased() makes of the route's Ref (Handles and ownership).
WidgetsAppneeds itspage_route_builder(whichFluentApp,CupertinoApp, andMaterialAppconfigure automatically): without it the app compiles, and panics on its first frame.
Every app widget shows Flutter's DEBUG ribbon in its top right corner, over the controls there, until
debug_show_checked_mode_banner(false)hides it.