简体   繁体   English

在 Flutter 中将 endDrawer 移动到 bottomNavigationBar 上方

[英]Move endDrawer above bottomNavigationBar in Flutter

We have a endDrawer that is displaying behind the bottomNavigationBar .我们有一个endDrawer显示在bottomNavigationBar后面 We want it to display over the navigation bar.我们希望它显示over导航栏上。

We may need a refactor but for now, we have a main Scaffold like so:我们可能需要重构,但现在,我们有一个像这样的主脚手架:

return Scaffold(
      key: shellKey,
      drawer: const MainDrawer(),
      body: child,
      extendBody: true,
      bottomNavigationBar: const ExpandingBottomDrawer(),
);

The router pushes the child to this Scaffold via router通过以下方式将child推送到这个脚手架

ShellRoute(builder: (context, state, child) => AppLayout(child: child),...)

The children are also Scaffolds that have independent endDrawers . children级也是具有独立endDrawersScaffolds In the children, I am triggering opening the endDrawer via _key.currentState.,openEndDrawer(), .在孩子们中,我通过_key.currentState.,openEndDrawer(),触发打开 endDrawer。 The issue is the endDrawer is visibly behind the bottomNavigationBar .问题是endDrawer明显位于bottomNavigationBar后面。 I understand this can be fixed if the endDrawer was on the main Scaffold, but the app is not set up that way and it would be a huge refactor.我知道如果endDrawer位于主脚手架上,则可以修复此问题,但应用程序未按此方式设置,这将是一个巨大的重构。 Is this possible without a refactor?如果没有重构,这可能吗?

Thank you!!谢谢!!

You can use another Scaffold widget.您可以使用另一个 Scaffold 小部件。

return Scaffold(
  drawer: const Drawer(),
  bottomNavigationBar: Container(
    child: Text("Bottom navBar"),
  ),
  body: Scaffold(
    appBar: AppBar(),
    drawer: const Drawer(),
  ),
);

There might be a better way of handling this.可能有更好的方法来处理这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM