繁体   English   中英

如何在flutter中将一个图标更改为两个不同的图标?

[英]How do I change one icon into two different icons in flutter?

如何在flutter中将一个图标更改为两个不同的图标? 这是我到目前为止。

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()),
  );
}

这是我曾经如何根据布尔值实现切换图标

bool _newNotification = false;
  Tab(
            icon: _newNotification
                ? Icon(
                    Icons.directions_boat,
                    size: 28,
                    color: Colors.white,
                  ),
                : Icon(
                    Icons.notifications,
                    size: 28,
                    color: Colors.white,
                  ),
),

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM