在Flutter中获取键盘高度 [英] Get keyboard height in Flutter

查看:2683
本文介绍了在Flutter中获取键盘高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在Flutter中获得开放式键盘的高度吗?我试图通过打开键盘的高度来填充 bottomSheet 小部件。

Is there any way to get an open keyboard's height in Flutter? I'm trying to pad a bottomSheet widget by the height of the keyboard while it's open.

推荐答案

通常 viewInsets 提供有关使抖动ui变得模糊的任何系统ui的数据。要了解键盘高度,只需在屏幕上显示键盘时,检查 viewInsets 底部属性,

您可以使用 viewInsets > MediaQuery ,例如:

You can check for the viewInsets with MediaQuery like:

MediaQuery.of(context).viewInsets.bottom

注意:即使其他系统,底部属性也可能有价值ui从底部遮住了颤动的ui。

Note: The bottom property may have value even if some other system ui obscures the flutter ui from bottom.

希望有帮助!

这篇关于在Flutter中获取键盘高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆