flutter 全局 提示_Flutter —如何全局关闭键盘
flutter 全局 提示
When working with Flutter, we regularly try to mimic platform-specific behaviors. For example, the keyboard on iOS usually hides automatically once the user taps any place in the screen out of a TextField.
与Flutter合作时,我们会定期尝试模仿特定于平台的行为。 例如,一旦用户从TextField中点击屏幕上的任何位置,iOS上的键盘通常会自动隐藏。
One way to replicate this is by controlling the Focus manually in each screen that contains a TextField; once it loses the Focus, we dismiss the keyboard. It is a tedious solution, prone error, and generates a lot of code.
一种复制方法是在每个包含TextField的屏幕中手动控制Focus。 一旦失去焦点,我们将关闭键盘。 这是一个乏味的解决方案,容易出错,并生成大量代码。
A better way is to set this behavior globally in our Flutter app:
更好的方法是在Flutter应用中全局设置此行为:
The builder method from MaterialApp can be used for inserting widgets above the Navigator but below the other widgets. We’ve simply added a “global” GestureDetector that will handle the keyboard dismiss for us. The result can be seen below:
MaterialApp的builder方法可用于在Navigator上方但在其他小部件下方插入小部件。 我们仅添加了一个“全局” GestureDetector ,它将为我们处理键盘关闭。 结果如下所示:
TextFields using the same "global" GestureDetector to dismiss the keyboard 使用相同的“全局” GestureDetector来关闭键盘的TextFieldTwitter️ 推特
翻译自: https://itnext.io/flutter-how-to-dismiss-keyboard-globally-a543452cfefa
flutter 全局 提示
- Win8系统使用键盘时出现键盘提示音请问如何关闭键盘提示音
- PHP如何关闭notice级别的错误提示
- 如何点击IE窗口上方的“X关闭符号”,弹出提示窗口呢?
- js如何关闭当前页,而不弹出提示框 尤其是万恶的IE||关闭子窗口同时刷新父窗口
- layer插件如何在弹出层中弹出一警告提示并关闭弹出层
- win7系统如何在没有外置键盘的情况下关闭小键盘
- 安卓的键盘如何 在启动时关闭
- VS如何关闭 ReSharper 提示
- 如何在javascript里用window.close(); 关闭窗口时不提示“是否要关闭本窗口”!
- IBM ThinkPad-如何激活和关闭数字小键盘
- 手机qq的“兴趣部落”如何关闭提示(小圆点)
- FineUI如何关闭窗体并弹出提示框
- C# WinForm 如何实现窗体的关闭时温馨提示
- QT如何捕获全局的键盘事件?
- 如何关闭Windows程序异常退出时的提示信息对话框
- JS关闭窗口而不弹出提示 如何让有滚动条的层自动滚动到最下
- PHP如何关闭notice级别的错误提示
- eclipse如何开启/关闭代码提示功能
- IntelliJ IDEA “Finds duplicated code”提示如何关闭
- 如何关闭Sublime Text2的更新提示?