当前位置:网站首页>The way that flutter makes the keyboard disappear (forwarding from the dependent window)

The way that flutter makes the keyboard disappear (forwarding from the dependent window)

2022-06-25 09:43:00 Moon Spring

Link to the original text : Forwarding self dependent window
In general , Add a gesture to the outermost layer , Click execute :

FocusScope.of(context).requestFocus(FocusNode());

Two general cases , If it's in H5 page , One more layer of interaction , At this time, the above method does not take effect , Then try the following method , It should be noted that , Here we need to follow H5 Interact , need H5 call Flutter Layer method ,

H5 call Flutter The method of requires the following settings :

WebView(
  javascriptChannels: <JavascriptChannel>[
    _hideKeyboardJavascriptChannel(context)
  ].toSet(),
)

JavascriptChannel _hideKeyboardJavascriptChannel(BuildContext context) {
    
  return JavascriptChannel(
      name: " This is with H5 Interactively customized Channel name ",
      onMessageReceived: (JavascriptMessage message) {
    
        SystemChannels.textInput.invokeMethod('TextInput.hide');
      });
}
原网站

版权声明
本文为[Moon Spring]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200549006110.html