flutter - 带有导航栏项的活动状态颤动的圆形背景
问题描述
我刚刚bottom bar navigation
在我的颤振应用程序中实现了一个。但是,我需要做最后一件事。我想添加一个 cicle 背景,以便在活动时与 Asset Icon 一起显示。我不知道该怎么做,因为我需要一些帮助。
现在,我的代码添加了文本和图像,但我需要有关如何使用我的代码添加背景的说明。
new BottomNavigationBarItem(
icon: ImageIcon(
AssetImage(
"assets/images/home.png",
),
size: 25,
),
title: Text(
"Home",
style: TextStyle(
fontWeight: FontWeight.w700,
fontFamily: 'Inter',
fontSize: _sizeConfig.textSize(
context,
1.7,
),
),
),
),
);
解决方案
一种方法是检查索引并相应地更改容器的颜色。
eg : 这里 index 存储当前屏幕索引
BottomNavigationBarItem(
icon: Container(
decoration: BoxDecoration(
color: index == 0 ? Colors.orange : Colors.transparent,
shape: BoxShape.circle),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.ac_unit),
),
),
title: Text(
"Home",
style: TextStyle(
fontWeight: FontWeight.w700,
fontFamily: 'Inter',
fontSize: _sizeConfig.textSize(
context,
1.7,
),
),
),
),
推荐阅读
- html - 引导网格没有正确包装?
- powershell - Powershell 变量未用作变量
- compression - Are Linear Quadtrees the most efficient way to store grid division data
- javascript - 未捕获的 ReferenceError:未定义 y (var)
- php - 将 $date 从 wordpress 中的高级自定义字段转换为 php 格式
- java - 带有 java 后端的 Git 克隆 Web 应用程序
- r - 股票价格数据的合计 5 分钟间隔
- bash - 用 cut 过滤 ping 的输出
- jmespath - JMESPath - 连接嵌套数组中的项目
- java - Java 在货币表示和货币转换方面的表现?