首页 > 解决方案 > 透明背景CurvedNavigationBar

问题描述

如何为 CurvedNavigationBar 做透明背景?

在此处输入图像描述

这是有关 CurvedNavigationBar 的代码:

bottomNavigationBar: CurvedNavigationBar(
        onTap: (int index) => setState(() => _currentIndex = index),
        index: _currentIndex,
        buttonBackgroundColor: SVConst.mainColor,
        backgroundColor: Colors.transparent,
        color: SVConst.mainColor,
        items: <Widget>[
          for (final tabItem in TabNavigationItem.items) tabItem.icon
        ],
      ),

如果您想了解更多,这是关于代表的 URL:

https://github.com/EliaTolin/StatusVaccini

谢谢。

标签: flutterdart

解决方案


这是许多 Flutter 开发者的共同要求,但插件仍然不支持。但是有一种间接的方法可以通过Stack这样的方式实现它:

Scaffold(
    body: Stack(
      children: <Widget>[

        //Place your scaffold body here
        Text('This is the body'),

        Align(
            alignment: Alignment.bottomCenter,
            child: CurvedNavigationBar(
             onTap: (int index) => setState(() => _currentIndex = index),
             index: _currentIndex,
             buttonBackgroundColor: SVConst.mainColor,
             backgroundColor: Colors.transparent,
             color: SVConst.mainColor,
             items: <Widget>[
              for (final tabItem in TabNavigationItem.items) tabItem.icon
             ],
          ),
        ),
      ],
    ),
  );

推荐阅读