![](/img/trans.png)
[英]How to change BottomNavigationBarItem icon when selected, Flutter
[英]How can I change this default Icon in "BottomNavigationBarItem" flutter
[我想更改此默认图标。 我怎样才能改变这个?]
BottomNavigationBarItem(
icon: Icon(
Icons.home,
size: 32,
),
label: "Tweets",
)
如果你只是想用另一个改变图标,你必须改变这里的代码:
BottomNavigationBarItem(
icon: Icon(
Icons.anotherIconNameHere, // after the dot you change your icon
size: 32,
),
label: "Tweets", // here you can change the icon's label
)
我在此处添加anotherIconNameHere
图标名称的地方是您将更改图标的位置:在Icons.
您可以指定要显示的图标。 如果您使用的是 IDE,例如 Android Studio 或 Visual Studio Code,则在键入点后,所有可用图标都会显示在弹出列表中。
您可以在此处查看图标 class 的所有可用图标:图标 class - 素材库 - Dart API
在素材图标 class 中,您几乎可以找到所需的所有图标。
编辑:如果您想添加自定义图标或您的图标,我强烈建议您阅读 Freecodecamp.org 上的这篇文章: FreeCodeCamp.Org - How to add custom icons to your flutter application
(如果这就是你要找的答案,记得给select吧。)
@ashikur 只需使用 Image.asset 加载本地图像。 您必须在资产文件夹和 pubspec 中添加。
BottomNavigationBarItem(
icon: Image.asset(
"assets/images/google.png"
),
label: "Tweets",
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.