IRouter的使用

IRouter.provider()

  1. app组件的initState里创建delegate和parser: _routeParser = IRouteParser( routes: { '/': (BuildContext context, Map<String, dynamic> params) => const FirstPage(), '/second': (context, params) => const SecondPage(), }, initialRoute: '/', );

    _routeState = IRouter(_routeParser);

    const _scaffoldKey = ValueKey('App scaffold'); _routerDelegate = IRouterDelegate( routeState: _routeState, navigatorKey: _navigatorKey, builder: (context) => IRootNavigator(navigatorKey: _navigatorKey, pages: _pages), );

    _pages = const MaterialPage<void>( key: _scaffoldKey, child: HomePage(), ), ;

  2. 其builder函数为 @override Widget build(BuildContext context) => IRouter.provider( _routeState, MaterialApp.router( routerDelegate: _routerDelegate, routeInformationParser: _routeParser), );

  3. 对于rail等组件,按照正常的写法,唯显示页面的部分,使用ITab Expanded( child: ITabNavigator( urls: const '/', '/second', index: _selectedIndex, tabId: 'ipage', )) 而控制部分,简单的使用: IRouter.push( context, routeState!.tabs'ipage'![index].currentUrl, index);

  4. push和pop: IRouter.push,IRouter.pop

Libraries

common
iconnect
idev
iroot_navigator
iroute_parser
irouter
irouter
irouter_delegate
itab_navigator
mixin
parsed_route
provider
store