Skip to content

Commit

Permalink
fix route config
Browse files Browse the repository at this point in the history
  • Loading branch information
Asscre committed Nov 11, 2021
1 parent 3c71849 commit db4cbc9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/pages/use_router/use_router_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:ssf/routes/custom_router.dart';

import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ssf/routes/routes_name.dart';

/// Custom Router基本用法
class UseRouterPage extends StatelessWidget {
Expand Down Expand Up @@ -38,7 +39,7 @@ class UseRouterPage extends StatelessWidget {
return TextButton(
onPressed: () => CustomRouter.toPage(
context,
'asscre/HowUseRouterPage',
RoutesName.HowUseRouterPage,
arguments: 'This is param for AsscrePage',
),
child: Text(
Expand Down
6 changes: 5 additions & 1 deletion lib/routes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
### 存放项目路由文件
### author: Asscre
### time: 09-03-2021
###
###

### CustomRouter: 路由跳转文件
### UseRouter: Use页面相关路由配置
### RoutesName: 所有路由地址集合
3 changes: 2 additions & 1 deletion lib/routes/custom_router.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/material.dart';
import 'package:ssf/common/page/not_find_page.dart';
import 'package:ssf/pages/home_pege.dart';
import 'package:ssf/routes/routes_name.dart';
import 'package:ssf/routes/use_router.dart';

/// CustomRouter
/// 通过模块划分管理router
/// 当然,你也可以在这里设置跳转动画
class CustomRouter {
static Map<String, Function> routes = {
"/": (context) => const HomePage(),
RoutesName.Root: (context) => const HomePage(),
};

/// 在这里,你可以随意添加你所划分的模块路由
Expand Down
5 changes: 5 additions & 0 deletions lib/routes/routes_name.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RoutesName {
static const Root = '/';

static const HowUseRouterPage = 'asscre/HowUseRouterPage';
}
3 changes: 2 additions & 1 deletion lib/routes/use_router.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import 'package:ssf/pages/use_router/how_use_router_page.dart';
import 'package:ssf/routes/routes_name.dart';

final Map<String, Function> useRouter = {
'asscre/HowUseRouterPage': (String incParam) => (_) => HowUseRouterPage(incParam),
RoutesName.HowUseRouterPage: (String incParam) => (_) => HowUseRouterPage(incParam),
};

0 comments on commit db4cbc9

Please sign in to comment.