|
- import 'package:flutter/material.dart';
- import 'package:zhiying_comm/pages/login_page.dart';
- import 'package:zhiying_comm/zhiying_comm.dart';
- import 'package:provider/provider.dart';
-
- class RouterUtil {
-
- static Future route(Map<String, dynamic> model, BuildContext context) {
- // 唯一跳转标识
- String skipIdentifier = model['skip_identifier'].toString();
- // 需要登录
- String requiredLogin = model['required_login'].toString();
- // 需要淘宝授权
- String requiredTaobaoAuth = model['required_taobao_auth'].toString();
-
-
- if (requiredLogin == '1') {
- UserInfoModel user = Provider.of<UserInfoNotifier>(context, listen: false).getUserInfoModel();
- print(user.toString());
- if (user?.token == null || user.token == '') {
- print('need login...');
- return Navigator.of(context)
- .push(MaterialPageRoute(builder: (BuildContext context) {
- return LoginPage();
- }));
- }
- }
-
- return Navigator.of(context)
- .push(MaterialPageRoute(builder: (BuildContext context) {
- if (PageFactory.hasRegisted(skipIdentifier)) {
- return PageFactory.create(skipIdentifier, model);
- }
- return EmptyPage();
- }));
- }
- }
|