我有一个定制的BottomNav栏,并成功地根据选定的索引更改了背景 colored颜色 .我通过一个三元声明来做到这一点:
backgroundColor: selectedIndex == 0
? const Color.fromARGB(255, 0, 52, 35)
: const Color.fromARGB(255, 0, 13, 52),
现在我已经添加了第三个屏幕,我想要设置一条IF语句,如下所示:
backgroundColor:
if (selectedIndex == 0)
{const Color.fromARGB(255, 0, 52, 35);}
if (selectedIndex == 1)
{const Color.fromARGB(255, 0, 13, 52);}
if (selectedIndex == 2)
{const Color.fromARGB(255, 87, 0, 54);},
这可能只是一个简单的语法问题--我还是个初学者.