ui_router 2.0.1 ui_router: ^2.0.1 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 ok
final router = UiRouter(
pages: {
'/a': (params) => PageA(),
'/b': (params) => PageB(),
'/c': (params) => PageC(),
},
);
Widget #
UiRouterWidget(router)
use Widget #
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 location (e.g. /a/b/c) #
router.location
path params #
pages: {
'/a/:id': (params) => Page(params['id']),
},
... ...
router.push('/a/7'); // id=7
initialLocatoin (e.g. /a/b/c) #
final router = UiRouter(
initialLocatoin: '/a/b/c',
...
);
Dialog #
init #
final router = UiRouter(
...
dialogs: {
'/x': (call) => DialogX(call),
'/y': (call) => DialogY(call),
},
);
Open Dialog #
final call = router.open('/x');
Event from Dialog #
call.event('USER-TAPPED-CANCEL');
Listen the Dialog event #
call.onEvent((value) {
// value='USER-TAPPED-CANCEL'
});
Close Dialog #
router.close();
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!