帮助!您需要将数据发送到 addDataToCart 函数,该函数应包含文档集合。我想使用相同的数据将文档从一个集合添加到另一个。我有一个收藏集门票,我想向该收藏集购物车中添加文档
因此,我尝试将此'$ {doc.data}'发送到 addDataToCart 函数,但这不起作用
Widget buildTicketsItem(BuildContext context, DocumentSnapshot doc,
TicketsBloc blocTickets, CartBloc blocCart) {
return Container(
color: Colors.blueGrey[900],
child: Slidable(
delegate: SlidableDrawerDelegate(),
actionExtentRatio: 0.25,
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.white,
backgroundImage: NetworkImage('${doc.data['image']}'),
),
title: Text('${doc.data['name']}'),
subtitle: Text('${doc.data['description']}'),
trailing: Text('${doc.data['price']}'),
),
actions: <Widget>[
IconSlideAction(
caption: 'Edit',
color: Colors.blue,
icon: Icons.edit,
onTap: () => editDialog(context, blocTickets, doc),
),
IconSlideAction(
caption: 'Delete',
color: Colors.red,
icon: Icons.delete,
onTap: () => blocTickets.deleteData(doc),
)
],
secondaryActions: <Widget>[
IconSlideAction(
caption: 'Add to Cart',
color: Colors.green,
icon: Icons.add,
onTap: () {
// validateAndAddDataToCart(blocCart);
blocCart.addDataToCart('${doc.data}');
},
)
],
),
);
}