diff --git a/lib/util/net_util.dart b/lib/util/net_util.dart index c4f651e..dd4220e 100644 --- a/lib/util/net_util.dart +++ b/lib/util/net_util.dart @@ -6,6 +6,7 @@ import 'dart:ui'; import 'package:device_info/device_info.dart'; import 'package:dio/adapter.dart'; import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:imei_plugin/imei_plugin.dart'; import 'package:package_info/package_info.dart'; @@ -16,10 +17,14 @@ import 'global_config.dart'; import 'shared_prefe_util.dart'; import 'time_util.dart'; +import 'package:provider/provider.dart'; + typedef OnSuccess = dynamic Function(dynamic data); typedef OnError = dynamic Function(String e); typedef OnCache = dynamic Function(dynamic data); +final GlobalKey navigatorKey = new GlobalKey(); + enum NetMethod { GET, POST, @@ -132,6 +137,19 @@ class NetUtil { ); } + // 退出登陆 + if(result[GlobalConfig.HTTP_RESPONSE_KEY_CODE]?.toString() == '401003'){ + try { + Future.delayed(Duration(seconds: 0)).then((onValue) { + BuildContext context = navigatorKey.currentState.overlay.context; + Provider.of(context, listen: false).unLogin(); + }); + + }catch(e,s ){ + Logger.error(e,s ); + } + } + return result; } } catch (e) {