如何删除或增加Flitter中导航栏中所选项目的装饰?

NavigationBar(
        elevation: 0,
        selectedIndex: navIndex,
        onDestinationSelected: (index) => setState(() {
          navIndex = index;
        }),
        backgroundColor: Colors.transparent,
        labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
        destinations: const [
          NavigationDestination(
            icon: Text('Your subscriptions'),
            label: '',
          ),
          NavigationDestination(
            icon: Text('Upcoming bills'),
            label: '',
          ),
        ],
      ),

装饰形象

推荐答案

通常,NavigationDestination图标必须是icon()小部件.

NavigationDestination(
        icon: <This has to be a Icon>
        label: '',
),

图标将使用"NavigationBarThemeData".iconTheme',如果"NavigationBarThemeData"不存在,图标将使用"IconThemeData".在这两种情况下,我都找不到改变突出显示区域大小的方法.

你可以这样做,它会做的工作,但不是那么顺利.

  int _selectedIndex = 0; // local variable



      NavigationDestination(
        icon: Container(
            decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(20)),
                color: _selectedIndex == 0 ? Colors.blue.shade100 : Colors.transparent,
                shape: BoxShape.rectangle),
            child: Padding(
              padding: const EdgeInsets.all(16.0),
              child: Text('Your subscriptions'),
            )),
        label: 'Your subscriptions',
      ),

Flutter相关问答推荐

点击表情符号按钮后,Flutter 文本域文本编辑控制器将文本恢复为原始值

如何使用Dio/Ffltter(前端)和amp;Go(后端)向API发送正确的请求

有没有什么方法可以加快在Flutter 中加载Quill HTML编辑器的速度?

如何使文本表格域在抖动中变圆?

Flutter 块消费者仅对特定的状态属性更改做出react

通过Ffltter应用程序与Docker服务器进行交互以进行身份验证

使索引[0]在ListViewBuilder中返回字符串1

抖动问题:检测到0个或2个或更多具有相同值的[DropdownMenuItem]

Flutter:无法构建iOS应用程序-找不到PigeonParser.h文件

如何在 Dart/Flutter 中克隆 Future

Flutter中pubspec.yaml文件中的name参数是什么?

像图像一样Flutter 自定义标签

当项目较少时收缩列表视图

Flutter中如何连续获取TextField的文本是否为空?

Flutter 如何使用 ClipPath 编辑容器的顶部?

如何在 Flutter 中将列小部件添加到行小部件?

.info/connected 这两个代码之间有什么区别吗?

Flutter:制作自定义小部件的最佳做法是什么?

使用 Firebase/Flutter 进行应用判断 - 100% 无效请求

Flutter MQTT - 发布到主题 1 并收听主题 2