简体   繁体   English

如何更改“BottomNavigationBarItem”中的默认图标 flutter

[英]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.我在此处添加anotherIconNameHere图标名称的地方是您将更改图标的位置:在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.如果您使用的是 IDE,例如 Android Studio 或 Visual Studio Code,则在键入点后,所有可用图标都会显示在弹出列表中。

You can check all the available icons of the Icons class here: Icons class - Material library - Dart API您可以在此处查看图标 class 的所有可用图标:图标 class - 素材库 - Dart API

In the material Icons class you can find pretty much all the icons you need.在素材图标 class 中,您几乎可以找到所需的所有图标。

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编辑:如果您想添加自定义图标或您的图标,我强烈建议您阅读 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.) (如果这就是你要找的答案,记得给select吧。)

@ashikur just use Image.asset to load local images. @ashikur 只需使用 Image.asset 加载本地图像。 that you have to add in the asset folder and in pubspec.您必须在资产文件夹和 pubspec 中添加。

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

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

相关问题 选择时如何更改 BottomNavigationBarItem 图标,Flutter - How to change BottomNavigationBarItem icon when selected, Flutter 如何更改 Flutter 中的 BottomNavigationBarItem 的 splashRadius - How to change the splashRadius of a BottomNavigationBarItem in Flutter 如何在 Flutter 的 BottomNavigationBarItem 中更改标签的颜色? - How do i change the label's color in a BottomNavigationBarItem in Flutter? 如何更改 BottomNavigationBarItem Flutter 标签中的 Fontfamily? - how to change Fontfamily in BottomNavigationBarItem Flutter label? 如何使 Flutter BottomNavigationBarItem 图标和 label 在同一行 - How to make Flutter BottomNavigationBarItem icon and label in same line 如何在 Flutter 中删除 BottomNavigationBarItem 的“图标”属性的填充? - How to remove padding of BottomNavigationBarItem's "icon" property in Flutter? 如何在颤动中更改抽屉图标? - How can I change Drawer icon in flutter? 如何为 BottomNavigationBarItem 添加阴影 - How can I add shadow to a BottomNavigationBarItem 如何更改 Flutter 中的默认前缀图标主题? - How to change default preffix icon theme in Flutter? Flutter BottomNavigationBarItem只接受Icon而没有其他小部件? - Flutter BottomNavigationBarItem accepts only Icon and no other widgets?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM