如何在颤动中将一个图标更改为两个不同的图标?这就是我到目前为止所拥有的。
Widget build(BuildContext context) {
final WebPage currentPage = webPages[currentPageIndex];
return Scaffold(
body: SafeArea(
child: WebView(
initialUrl: currentPage.url,
javaScriptMode: JavaScriptMode.unrestricted,
onWebViewCreated: _controller.complete,
),
),
bottomNavigationBar: BottomNavigationBar(
onTap: onTapNavigation,
currentIndex: currentPageIndex,
items: webPages
.map((webPage) => BottomNavigationBarItem(
icon: Icon(Icons.school), title: Text(webPage.title)))
.toList()),
);
}
答案 0 :(得分:0)
这是我曾经基于bool值实现切换图标的方式
bool _newNotification = false;
Tab(
icon: _newNotification
? Icon(
Icons.directions_boat,
size: 28,
color: Colors.white,
),
: Icon(
Icons.notifications,
size: 28,
color: Colors.white,
),
),