captain 0.0.2-nullsafety captain: ^0.0.2-nullsafety copied to clipboard
declarative routing with an imperative facade. Captain manages Router (Navigator 2.0) logic by providing well defined API in old school format
Captain #
an imperative way to navigate declaratively
Placing it in the widget tree #
place the Captain()
widget at the same postition inside your widget tree where your Router or Navigator widget would reside. Best practice is placing the main Router beneath the Material/Cupertino/WidgetsApp like:
...
MaterialApp(
home: Captain(
pages: ...,
...
),
),
Navigate with Captain #
Captain supports imperative navigation style by complying to the Navigator.of(context)
format
Use either:
.action(Object actionKey)
for invoking predefined actions that have been registered to the Captain Widget.actionFunc(List<Page> Function(List<Page>))
which takes a List
Example #
Navigator.of(context).action("myActionKey");
Navigator.of(context).actionFunc((pageStack) => pageStack..add(pageToAdd));