Bladeren bron

1、路由跳转。输入框的隐藏

tags/0.0.1
PH2 4 jaren geleden
bovenliggende
commit
74e9b4248c
1 gewijzigde bestanden met toevoegingen van 17 en 1 verwijderingen
  1. +17
    -1
      lib/util/router_util.dart

+ 17
- 1
lib/util/router_util.dart Bestand weergeven

@@ -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…
Annuleren
Opslaan