我正在开发一个跟踪器应用程序,其中每个产品都有三个跟踪器。单击每个跟踪器图标后,当前时间将存储到Firestore中。 现在,我需要通过获取Firestore数据来检索是否已单击跟踪器。在获取Firestore数据时,如果Tracker字段为空,则将布尔值传递给Tracker图标。问题是此布尔值正在获取因此,如果Firestore中的最后一个值为true,则所有跟踪器图标都变为绿色(Green = true和Black = false)
这是即时消息生成三个可点击的跟踪器图标的方式:
List<Widget> _buildTracker() {
var wids = <Widget>[];
widget._stepsText.asMap().forEach((i, text) {
wids.add(Expanded(
child: FavoriteWidget(text, widget.title, widget.selectedDay, widget.drugId,retreat),
));
}
收藏夹小部件:
class _FavoriteWidgetState extends State<FavoriteWidget> {
bool _isFavorited = false;
bool ree = false;
String step = "";
@override
Widget build(BuildContext context) {
DateTime now1 = DateTime.now();
var formatter = new DateFormat('yyyy-MM-dd');
String formatted = formatter.format(widget.selectedDay);
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
(widget.selectedDay.isAfter(now1))
? Container(
padding: EdgeInsets.all(0),
child: IconButton(icon: Icon(Icons.healing), onPressed: null))
: Container(
padding: EdgeInsets.all(0),
child: IconButton(
icon: ((_isFavorited) //==>default is false.I need this
//value to be getting from the
//firestore.
? Icon(Icons.healing, color: Colors.green)
: Icon(Icons.healing, color: Colors.black)),
onPressed: () {
//Code to upload the time in firestore
});
}
}