我试图在点击时更改我的 SVG 图标颜色。我已经尝试过,selectedColor但图标没有改变颜色。所以我尝试使用快捷方式 if...else 语句,但我仍然没有改变颜色。
这是代码:
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/dashboard-outline.svg', width: 25),
label: 'Dashboard'
),
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/tank-outline.svg', color: Colors.black54, width: 30),
label: 'Tanks',
),
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/activity-outline.svg', width: 18),
label: 'Activity'
),
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/account-outline.svg', width: 20),
label: 'Account'
),
],
currentIndex: _index,
onTap: _onItemTapped,
selectedItemColor: Color.fromRGBO(0,99,183,1)
),
Run Code Online (Sandbox Code Playgroud)
我有一个不同的 SVG 图片图标文件,可以在点击时更改它。
这是我正在尝试的代码:
bool onSelected = true;
Widget build(BuildContext context) {
return Scaffold(
body: _myPages[_index],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: …Run Code Online (Sandbox Code Playgroud) 我在徘徊如何制作一个同时上下的循环。
例如,这是正常循环:
for(let i = 0; i < number.length; i++){}
for(let i = 0; i < number.length; i--){}
Run Code Online (Sandbox Code Playgroud)
我怎样才能简化这个循环?