kevin-sakemaer/flouter
一個基於 Navigator 2.0 和正則表達式的 Flutter 路由
- Stars
- 40
- Forks
- 4
- 最近推送(UTC)
- 2021年3月4日
- 專案狀態
- 未封存
語言DartHTMLSwiftKotlinObjective-C
技術主題
使用的依賴
原始 README
以下為英文專案原文快照,最新內容請造訪 GitHub。
展開 / 收合專案 README
A Navigator 2.0 router for Flutter
Easy to use router library that do all the work for you !
Easy
First create a MaterialApp.router :
return MaterialApp.router(
title: 'Uri navigator App',
routerDelegate: _routerDelegate,
routeInformationParser: UriRouteInformationParser(),
);
Second initialize your _routerDelegate like this :
final _routerDelegate = UriRouterDelegate(
pageNotFound: (routeInformation) => MaterialPage(
key: ValueKey('not-found-page'),
child: Scaffold(
body: Center(
child: Text('Page ${routeInformation.uri.path} not found'),
),
),
),
initialUris: [
Uri.parse('/'),
Uri.parse('/test/titi/'),
],
pages: {
RegExp(r'^/$'): (_) => HomePage(),
RegExp(r'^/test/([a-z]+)/$'): (routeInformation) => TestPage(routeInformation),
},
);
That's all you have to do ;)