简体   繁体   中英

How can I change this default Icon in "BottomNavigationBarItem" flutter

[I want to change this default icon. How can I change this?]

        BottomNavigationBarItem(
          icon: Icon(
            Icons.home,
            size: 32,
          ),
          label: "Tweets",
        )

If you just want to change the icon with another one, you have to change the code here:

BottomNavigationBarItem(
      icon: Icon(
        Icons.anotherIconNameHere, // after the dot you change your icon
        size: 32,
      ),
      label: "Tweets", // here you can change the icon's label
    )

Where I added anotherIconNameHere is where you will change your icon: after Icons. you can specify the icon you want to show. If you are using an IDE like Android Studio or Visual Studio Code, after typing the dot all the available icons will show up in a popover list.

You can check all the available icons of the Icons class here: Icons class - Material library - Dart API

In the material Icons class you can find pretty much all the icons you need.

Edited: In case you want to add custom icons or your icons, I strongly suggest you to read this article from Freecodecamp.org: FreeCodeCamp.Org - How to add custom icons to your flutter application

(If this was the answer you were looking for, remember to select it.)

@ashikur just use Image.asset to load local images. that you have to add in the asset folder and in pubspec.

BottomNavigationBarItem(
      icon: Image.asset(
        "assets/images/google.png"
      ),
      label: "Tweets",
    )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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