如何在flutter上修改父FloatingActionButton?

问题描述 投票:2回答:1

我正在制作一个应用程序,其中我必须有页面,并由BottomNavigationBar路由,每个页面都有自己的嵌套路由。该应用程序包含一个主要的FloatingActionButton,该按钮居中并停靠在BottomNavigationBar中。问题是我想从每个嵌套路线内部控制FAB的功能。问题是,如果我在每个嵌套路线内创建一个FAB,该按钮将不会停靠在BottomNavigationBar中。波纹管是一些图片。有人可以帮忙吗?预先感谢。

What I have

What I wanted

flutter flutter-layout floating-action-button
1个回答
0
投票

这是您要问的吗?如果没有,请分享一些代码中的问题[]

Scaffold(
      appBar: AppBar(
        title: Text('Test'),
      ),
      body: Container(),
      bottomNavigationBar: Container(
        height: 50,
        child: BottomAppBar(
          color: Colors.grey,
          //shape: CircularNotchedRectangle(), //<-- uncomment for notched
          child: Container(),
        ),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      floatingActionButton: FloatingActionButton(
        child: Icon(
          Icons.android,
        ),
        onPressed: () {},
      ),
    );

输出

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.