image - Flutter:使用图像而不是图标
问题描述
我有一个无线电流播放器的示例代码。该代码提供了一个图标来表示其状态(暂停或播放)。我想显示图像而不是图标。
作为一个新手/菜鸟,我被卡住了。有人能把我推向正确的方向吗?
这是当前代码:
...........
default:
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
IconButton(
onPressed: () async {
print("button press data: " +
snapshot.data.toString());
await _flutterRadioPlayer.playOrPause();
},
icon: snapshot.data ==
FlutterRadioPlayer
.flutter_radio_playing
? Icon(Icons.pause)
: Icon(Icons.play_arrow))
]);
break;
}
...............
所以简而言之,我想使用一个图像,“pause.png”用于 Icons.pause,“play.png”用于 Icons.play_arrow。
解决方案
该图标是 Widget 类型,因此您可以传递例如 Image.asset([path to asset]) 而不是 Icon()
推荐阅读
- php - 每次插入 (int)$_GET['id']; 时我都会得到 0 值 在数据库中
- apache - 使用 htaccess 访问具有不同名称的相同文件
- java - 列表视图不显示来自自定义数组适配器的项目
- r - 在 R 中,如何使用不同的标签设置和保留自定义级别?
- makefile - 使用 Lua 脚本运行 HAProxy
- docker - docker 图像未显示在控制台中,但显示在 docker hub 中(允许某人许可)
- python - 将 ELMO 与 Keras 一起使用?
- android - 根据房间选择活动
- google-apps-script - 将 html 转换为 Google 文档
- reactjs - react-snap 没有这样的文件或目录