[英]Centering Floating Action Button in navigation bar Flutter
I have created a navigation bar in flutter, now I want to add a button in between the navbar icons as shown in this image.我在颤振中创建了一个导航栏,现在我想在导航栏图标之间添加一个按钮,如图所示。 I want this
我要这个
But I am getting this.但我得到了这个。 I am getting this
我得到这个
I brought the button in the middle with following code:我将按钮放在中间,代码如下:
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(PhosphorIcons.plusLight,color: navBarColor),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
Is there any way to bring it in the middle of the navbar?有没有办法把它放在导航栏的中间?
If there is a there is a way to give circle background color to a navbar destination, then it would be better.如果有一种方法可以为导航栏目的地提供圆形背景颜色,那么它会更好。
Try adding an alignment to the fab尝试向晶圆厂添加对齐方式
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
floatingActionButton: Align(
alignment: Alignment.bottomCenter,
child: Container(
padding: const EdgeInsets.only(bottom: 6.0),
child: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
),
),
floatingActionButton: Stack( [ Position( bottom: -20, FloatingActionButton( onPressed: () {}, child: const Icon(PhosphorIcons.plusLight,color: navBarColor), ) ) ]), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
Do not use a FloatingActionButton with a navbar like that.不要将 FloatingActionButton 与这样的导航栏一起使用。 Just add the + action as another button in the middle of the navbar.
只需将 + 操作添加为导航栏中间的另一个按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.