简体   繁体   English

使用浮动操作按钮将渐变颜色应用于底部导航栏

[英]Apply Gradient colours to Bottom Nav bar with floating action button

I need to make a nav bar with a floating action button just like this image:我需要制作一个带有浮动操作按钮的导航栏,就像这张图片一样:

在此处输入图像描述

what I have been able to make is in this picture:我能做的是这张照片:

在此处输入图像描述

The problem is that I wrapped my raw in a container, added box decoration to apply gradient property to my bottom nav bar which ended up deleting the white curve of the floating action button inside the nabber.问题是我将 raw 包装在一个容器中,添加了框装饰以将渐变属性应用于我的底部导航栏,最终删除了 nabber 内浮动操作按钮的白色曲线。 I want to be able to preserve the white curve just like in the first image and be able to apply gradient colours only to my nav bar is it possible to do so without using a box decoration?我希望能够像在第一张图像中一样保留白色曲线,并且能够仅将渐变颜色应用于我的导航栏,是否可以在不使用框装饰的情况下这样做?

Here's my code currently:这是我目前的代码:

 Widget build(BuildContext context) {
    return SafeArea(child:
    Scaffold(

        floatingActionButton:FloatingActionButton( //Floating action button on Scaffold
          onPressed: (){
            //code to execute on button press
          },
          child: Icon(Icons.add), //icon inside button
          backgroundColor: kPrimaryColor,
        ),

        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        //floating action button position to center

        bottomNavigationBar: Container(

            decoration: const BoxDecoration(
              borderRadius: BorderRadius.only(
                  topRight: Radius.circular(30), topLeft: Radius.circular(30)),
              color: Colors.white,
            ),

            child: ClipRRect(
              borderRadius: const BorderRadius.only(
                topLeft: Radius.circular(30.0),
                topRight: Radius.circular(30.0),

              ),
              child: BottomAppBar( //bottom navigation bar on scaffold
                color:Colors.transparent,
                shape: CircularNotchedRectangle(), //shape of notch
                notchMargin: 5, //notche margin between floating button and bottom appbar
                child: Container(
                  decoration: const BoxDecoration(
                    gradient: LinearGradient(
                      colors: [kPrimaryColor, kPrimaryLightColor],
                      begin: Alignment.topLeft,
                      end: Alignment.topRight,
                      stops: [0.1, 0.8],
                      tileMode: TileMode.clamp,
                    ),
                  ),
                  child: Row( //children inside bottom appbar
                    mainAxisSize: MainAxisSize.max,
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      IconButton(icon: Icon(Icons.home_filled, color: Colors.white,), onPressed: () {},),
                      IconButton(icon: Icon(Icons.check_circle, color: Colors.white,), onPressed: () {},),
                      IconButton(icon: Icon(Icons.analytics, color: Colors.white,), onPressed: () {},),
                      IconButton(icon: Icon(Icons.person, color: Colors.white,), onPressed: () {},),
                    ],
                  ),
                ),
              ),
            )
        )
    )  );
  }

If anyone knows the answer or can help I'd be grateful.如果有人知道答案或可以提供帮助,我将不胜感激。

Add this inside the BottomAppBar在 BottomAppBar 添加这个

clipBehavior: Clip.antiAlias,

暂无
暂无

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

相关问题 Flutter 中的浮动底部导航栏和浮动操作按钮 - Floating Bottom Nav Bar and Floating Action Button in Flutter Flutter 转换 animation 打破底部导航栏中浮动操作按钮的“按下” function。 需要解决方法 - Flutter transform animation breaks “on pressed” function of floating action button in bottom nav bar. Workaround needed 如何使用具有良好动画颤动的动态浮动动作按钮创建底部导航栏? - how to create bottom nav bar with dynamic floating action button with good animation flutter? 带有浮动操作按钮的底部导航栏 flutter - bottom navigation bar with Floating Action Button flutter Flutter 使浮动动作粘在底部导航栏 - Flutter make floating action stick to bottom nav bar 如何在带边框的中心底部导航栏中添加浮动操作按钮? - How to add Floating action Button in Bottom Navigation Bar in Center with border? 如何在带有缺口的底部导航栏中心添加浮动操作按钮? - How to add Floating action Button in Bottom Navigation Bar Center with notch? 底部导航栏中的可扩展浮动操作按钮 - Flutter - Expandable Floating Action button in bottom navigation bar - Flutter 如何制作径向渐变浮动动作按钮 - How to make a radial gradient floating action button 如何使用浮动操作按钮自定义底部导航栏以及左右曲线设计? - How to customize a bottom navigation bar in flutter with floating action button and and also curve design to the left and right?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM