hideKeyboard function

void hideKeyboard(
  1. BuildContext context
)

全局隐藏键盘

Implementation

void hideKeyboard(BuildContext context) {
  FocusScopeNode currentFocus = FocusScope.of(context);
  if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
    FocusManager.instance.primaryFocus?.unfocus();
    // SystemChannels.textInput.invokeMethod('TextInput.hide');
  }
}