簡體   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