我正在探索 flutter-web 并想在其中添加谷歌地图。虽然,我在 flutter-app 中使用 google_maps_flutter 使用了谷歌地图,但这适用于 Android 和 iOS。
想要改变点击时图标的颜色。默认情况下,如果项目已收藏,则图标为红色,而其他图标为默认颜色。
如果用户点击图标将其设为收藏或不收藏,我想在更新后更改颜色。
new ListTile(
trailing: InkWell(
child: Icon(Icons.share),
),
leading: InkWell(
onTap: () {
snapshot.data[index].isFavorite == 0
? makeFavorite(snapshot.data[index].id)
: makeUnfavorite(
snapshot.data[index].id);
},
child: snapshot.data[index].isFavorite == 1
? Icon(
Icons.favorite,
color: Colors.red,
)
: Icon(Icons.favorite)),
title: new Text(snapshot.data[index].body,
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 14.0)),
),
Run Code Online (Sandbox Code Playgroud)