英文:
Flutter Keyboard padding not working after I upgraded to Flutter 3.10. How to prevent BottomSheet from being overlapped by keyboard in Flutter 3.10?
问题
I use MediaQuery.of(context).viewInsets.bottom to determine padding according to Keyboard size. after upgrading to Flutter 3.10 now the bottomsheet is overlapped by the keyboard!
void onTotalsButtonPressed() {
showModalBottomSheet(
context: context,
builder: (context) => SingleChildScrollView(
padding:
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: AddProduct(
items: Provider.of<Products>(context, listen: false).searchItems,
type: OrderTypes.sales,
),
),
isScrollControlled: true,
);
}
When I build the app with Flutter 3.7.12 on my other machine it works well and padding is determined dynamically according to keyboard state!
英文:
I use MediaQuery.of(context).viewInsets.bottom to determine padding according to Keyboard size. after upgrading to Flutter 3.10 now the bottomsheet is overlapped by the keyboard!
void onTotalsButtonPressed() {
showModalBottomSheet(
context: context,
builder: (context) => SingleChildScrollView(
padding:
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: AddProduct(
items: Provider.of<Products>(context, listen: false).searchItems,
type: OrderTypes.sales,
),
),
isScrollControlled: true,
);
}
When I build the app with Flutter 3.7.12 on my other machine it works well and padding is determined dynamically according to keyboard state!
答案1
得分: 5
我遇到了相同的问题。
如果您正在使用ScreenUtil,您将需要使用v5.8.1,并将useInheritedMediaQuery
设置为true
。
英文:
I was facing the same issue.
If you are using ScreenUtil, you will have to use v5.8.1 and set useInheritedMediaQuery
to true
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论