ui_router 2.0.4 ui_router: ^2.0.4 copied to clipboard
Simple Router for Pages, Dialogs, Loading tasks. Powerful functions, interfaces will support your app.
Simple Router for Pages, Dialogs, Loading #
https://pub.dev/packages/ui_router
init #
// global
final router = UiRouter(
pages: {
'/a': (params) => PageA(),
'/b': (params) => PageB(),
'/c': (params) => PageC(),
},
);
Widget #
UiRouterWidget(router)
(Widget usage sample) #
main() {
final widget = UiRouterWidget(router);
final app = MaterialApp(home: widget);
runApp(app);
}
push (go to page B) #
router.push('/b');
pop (back one page) #
router.pop();
pop until the specific page #
router.pop(until: '/a');
current path stack #
router.pathStack
use path params #
pages: {
'/a/:id': (params) => Page(params['id']),
},
... ...
router.push('/a/7'); // id=7
start with a root path #
final router = UiRouter(
rootPath: '/b',
...
);
Dialog #
init #
final router = UiRouter(
...
dialogs: {
'/x': (call) => DialogX(call),
'/y': (call) => DialogY(call),
},
);
Open Dialog #
final call = router.open('/x');
Event on the Dialog #
call.event('USER-TAPPED-CANCEL');
Listen the event #
call.onEvent((value) {
// value='USER-TAPPED-CANCEL'
});
Close Dialog #
router.close(call);
Loading #
show loading with a task #
router.loading(
label: 'Now Loading...',
task: () async {
await Future.delayed(Duration(seconds: 5));
},
);
😄 Using Navigator 2.0
🎉 Contributions, issues are welcomed!