idev

Last updated:

0 purchases

idev Image
idev Images
Add to Cart

Description:

idev

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

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.