【问题标题】:How do I change one icon into two different icons in flutter?如何在颤动中将一个图标更改为两个不同的图标?
【发布时间】:2019-11-23 00:50:29
【问题描述】:

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

【问题讨论】:

    标签: javascript java android flutter dart


    【解决方案1】:

    这是我曾经根据布尔值实现切换图标的方式

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

    【讨论】:

      猜你喜欢
      • 2020-06-13
      • 1970-01-01
      • 2020-04-20
      • 1970-01-01
      • 2011-02-05
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多