1234567891011121314151617181920212223242526272829303132333435363738 |
- import 'package:flutter/scheduler.dart';
- import 'package:get/get.dart';
- import 'package:get_storage/get_storage.dart';
- import 'package:farmer_client/utils/tool.dart';
-
- var whiteList = [
- '/',
- '/splash',
- '/login',
- '/agreement',
- ];
-
- void routingCallback(routing) {
- print("---------routingCallback---------");
- print(routing?.current);
- print(whiteList.contains(routing?.current));
-
- if (!isLogin()) {
- if (!whiteList.contains(routing?.current)) {
- print('----will be to login page----->');
-
- // addPostFrameCallback 作用是等当前帧绘制完成之后再加载
- // https://github.com/jonataslaw/getx/issues/262
- SchedulerBinding.instance
- ?.addPostFrameCallback((_) => Get.offNamed('/login'));
- }
- }
-
- // bool isLogin = box.hasData('token');
- // bool isSplashScreen = routing?.current == '/splash';
- // bool isLoginPage = routing?.current == '/login';
- // bool isAgreementPage = routing?.current == '/agreement';
- // if (!isLogin && !isSplashScreen && !isLoginPage&&!isAgreementPage) {
- // addPostFrameCallback 作用是等当前帧绘制完成之后再加载
- // https://github.com/jonataslaw/getx/issues/262
- // SchedulerBinding.instance?.addPostFrameCallback((_) => Get.offNamed('/login'));
- // }
- }
|