From 54ed4e9f7f6f40c6cea85c15083d3cee8dbd8b72 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Thu, 22 Oct 2020 17:43:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E7=A9=BA=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E7=9A=84=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/util/empty_util.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/util/empty_util.dart b/lib/util/empty_util.dart index 22691df..a0f6b62 100644 --- a/lib/util/empty_util.dart +++ b/lib/util/empty_util.dart @@ -4,14 +4,14 @@ class EmptyUtil { /// 判断是否为空,object的类型可以为:String Map List static bool isEmpty(Object object) { if (null == object) return true; - if (object is String && object.isEmpty) { + if (object is String && (object.isEmpty || object.length == 0)) { return true; } - if (object is List && object.isEmpty) { + if (object is List && (object.isEmpty || object.length == 0)) { return true; } - if (object is Map && object.isEmpty) { + if (object is Map && (object.isEmpty || object.length == 0)) { return true; } return false; From 74e9b4248cdd1f3c13ad6807b3a03c1daccd11db Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Fri, 23 Oct 2020 15:10:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E8=B7=AF=E7=94=B1=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E3=80=82=E8=BE=93=E5=85=A5=E6=A1=86=E7=9A=84=E9=9A=90?= =?UTF-8?q?=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/util/router_util.dart | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/util/router_util.dart b/lib/util/router_util.dart index fbd1fce..834ad4d 100644 --- a/lib/util/router_util.dart +++ b/lib/util/router_util.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:zhiying_comm/pages/login_page/login_page.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -16,7 +17,7 @@ class RouterUtil { return Future.error('skipIdentifier 参数不存在,无法跳转页面'); } print('skipIdentifier: ${skipModel.skipIdentifier}'); - + hideKeyboard(context); if (skipModel?.requiredLogin == '1') { UserInfoModel user = await Provider.of(context, listen: false) @@ -62,4 +63,19 @@ class RouterUtil { model.url = url; RouterUtil.route(model, null, context); } + + + static void hideKeyboard(BuildContext context){ + try { + FocusScopeNode currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus && + currentFocus.focusedChild != null) { + FocusManager.instance.primaryFocus.unfocus(); + } + // SystemChannels.textInput.invokeMethod('TextInput.hide'); + // FocusScope.of(context).requestFocus(FocusNode()); + }catch(e, s){ + Logger.error(e,s); + } + } }