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?

huangapple go评论67阅读模式
英文:

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) =&gt; SingleChildScrollView(
        padding:
            EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
        child: AddProduct(
          items: Provider.of&lt;Products&gt;(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

huangapple
  • 本文由 发表于 2023年5月14日 19:51:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76247333.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定