-
Notifications
You must be signed in to change notification settings - Fork 0
Navigation
Efra Espada edited this page Jul 3, 2024
·
2 revisions
To navigate to another screen simply compose the URL to which it corresponds:
[SecondaryPage.routeName].route();
[SecondaryPage.routeName, 'other_param_id'].route();
You can invoke the route()
method directly to navigate to another screen, but here we recommend you this way from the Presenter:
After generating your screen, include in the base of the presenter a method that will take care of the navigation on that screen.
abstract class BaseMainPresenter extends MainPresenterDefinition {
@override
MainViewModel model = MainViewModel();
void goToNextScreen();
}
Implementa este método en el Presenter ejecutando el método route()
.
class MainPresenter extends BaseMainPresenter {
@override
void goToNextScreen() => [SecondaryPage.routeName].route();
}
In the widget, invoke the method you just implemented to navigate the other screen.
class MainPageState extends MainLifecycle {
@override
Widget onBuild(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text("Main Screen"),
),
floatingActionButton: FloatingActionButton(
onPressed: presenter.goToNextScreen,
tooltip: 'Navigate',
child: const Icon(Icons.navigate_next),
),
);
}
}