From 13e63e5a2e0f8b6067f5ef36585541b4bd14d0bb Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Sat, 14 Nov 2020 18:52:47 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=8D=95=E7=82=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E6=89=A7=E8=A1=8C=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= =?UTF-8?q?(=E4=B8=B4=E6=97=B6=E8=A7=A3=E5=86=B3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/util/net_util.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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) {