如何在原生底部导航栏上显示Flutter底部表单和对话框框?

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

How to show flutter bottom sheets, dialogue boxes over native bottom navigation bar?

问题

我正在将一个使用Flutter创建的屏幕集成到现有的原生应用中。原生应用有一个底部导航栏,该导航栏在所有屏幕上都存在。Flutter屏幕需要显示底部表和对话框,但所有这些只显示在底部导航栏(顶部导航栏也是如此)的后面。理想情况下,它应该显示在所有UI元素的顶部。我该如何做到这一点?

英文:

I'm integrating a screen done in flutter to an existing native app. The native app has a bottom navigation bar that is present on all screens. The flutter screen needs to show bottom sheets and dialogue boxes, but all of these only show behind the bottom navigation bar (top navigation bar as well). Ideally, it should appear on top of all UI elements. How can I do that?

答案1

得分: 1

showModalBottomSheet方法中将useRootNavigator标记为true

代码如下:

showModalBottomSheet(
     shape: const RoundedRectangleBorder(
       borderRadius: BorderRadius.only(
         topLeft: Radius.circular(25.0),
         topRight: Radius.circular(25.0),
       ),
     ),
     backgroundColor: Colors.white,
     context: context,
     isScrollControlled: true,
     useRootNavigator: true, /// 添加这一行以在导航栏上显示底部表单    
     builder: (BuildContext context) {
      return YourBottomLayout();
     },
);
英文:

mark useRootNavigator as true in showModalBottomSheet method

code shows like below:

showModalBottomSheet(
     shape: const RoundedRectangleBorder(
       borderRadius: BorderRadius.only(
         topLeft: Radius.circular(25.0),
         topRight: Radius.circular(25.0),
       ),
     ),
     backgroundColor: Colors.white,
     context: context,
     isScrollControlled: true,
     useRootNavigator: true, /// add this line to show bottomsheet over navbar    
     builder: (BuildContext context) {
      return YourBottomLayout();
     },
    );

huangapple
  • 本文由 发表于 2023年1月6日 15:00:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75027896.html
匿名

发表评论

匿名网友

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

确定