idev 0.1.3 idev: ^0.1.3 copied to clipboard
tools for flutter app in real product
IRouter的使用 #
IRouter.provider()
-
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
-
其builder函数为 @override Widget build(BuildContext context) => IRouter.provider( _routeState, MaterialApp.router( routerDelegate: _routerDelegate, routeInformationParser: _routeParser), );
-
对于rail等组件,按照正常的写法,唯显示页面的部分,使用ITab Expanded( child: ITabNavigator( urls: const ['/', '/second'], index: _selectedIndex, tabId: 'ipage', )) 而控制部分,简单的使用: IRouter.push( context, routeState!.tabs['ipage']![index].currentUrl, index);
-
push和pop: IRouter.push,IRouter.pop