不同设备上键盘高度的问题 // 如何正确使用 viewInsets
我有一些朋友测试了我的应用程序,并在其中一个设备上测试了键盘打开时,它隐藏了UI的一部分(复选框)。此屏幕截图显示问题(下面我的代码):
我的相关代码从模态底部表。我不使用100%的视图插图,因为我可以覆盖的某些部分。 0.38是产生两个结果的值,构成了屏幕截图。如何在各个设备之间保持一致?
return StatefulBuilder(
builder: (BuildContext context, StateSetter setModalState) {
return Padding(
padding: MediaQuery.of(context).viewInsets * 0.38,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [//irrelevant
],
I'm having some friends test an app of mine and on one of their devices, when the keyboard is open, it hides part of the UI (a checkbox). This screenshot shows the issue (my code below):
Below my relevant code from the modal bottom sheet. I'm not using 100% of the view insets, as I'm fine with some part of the sheet being covered. The 0.38 is the value that produces both results form the screenshot. How can I make this consistent across devices?
return StatefulBuilder(
builder: (BuildContext context, StateSetter setModalState) {
return Padding(
padding: MediaQuery.of(context).viewInsets * 0.38,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [//irrelevant
],
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用
padding:EdgeInsets.fromLTRB(0, 0, 0, MediaQuery.viewInsetsOf(context).bottom),
在这里,LTRB 表示左、上、右、下。
当您在底部使用
MediaQuery.viewInsetsOf(context).bottom)
您的 UI 将位于键盘顶部。You have to use
padding:EdgeInsets.fromLTRB(0, 0, 0, MediaQuery.viewInsetsOf(context).bottom),
In here, LTRB means Left, Top, Right, Bottom.
When in bottom you use
MediaQuery.viewInsetsOf(context).bottom)
your UI will be on top of Keyboard.