Weller vor 4 Jahren
Ursprung
Commit
f4b57016cc
2 geänderte Dateien mit 20 neuen und 4 gelöschten Zeilen
  1. +3
    -3
      lib/util/empty_util.dart
  2. +17
    -1
      lib/util/router_util.dart

+ 3
- 3
lib/util/empty_util.dart Datei anzeigen

@@ -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;


+ 17
- 1
lib/util/router_util.dart Datei anzeigen

@@ -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<UserInfoNotifier>(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);
}
}
}

Laden…
Abbrechen
Speichern