[英]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.