我的数据库中有数据,该数据是根据标准使用相同的文本创建的。但是我添加了一个应该更新数据的函数,当我调用它时,数据将更新为 空
类DB_tickets
void updateData(
DocumentSnapshot doc,
String description,
String image,
String name,
String price,
) async {
await db.collection('tickets').document(doc.documentID).updateData({
'description': '$description',
'image': '$image',
'name': '$name',
'price': '$price',
});
}
类TicketsBloc
void updateData(
DocumentSnapshot doc,
String description,
String image,
String name,
String price,
) {
db.updateData(doc, description, image, name, price);
}
这是我更新数据的主类,我以某种形式编写数据,并且很难在数据库中更新我输入的值,但是可惜,它与null不一样< / strong>
String description, image, name, price;
ListTile(
leading: Icon(Icons.assignment),
title: TextFormField(
onSaved: (input) => name = input,
decoration: InputDecoration(
hintText: "Name",
),
),
),
ListTile(
leading: Icon(Icons.assignment),
title: TextFormField(
onSaved: (input) => description = input,
decoration: InputDecoration(
hintText: "Description",
),
),
),
ListTile(
leading: Icon(Icons.assignment),
title: TextFormField(
onSaved: (input) => price = input,
decoration: InputDecoration(
hintText: "Price",
),
),
),
SimpleDialogOption(
child: Text('Save'),
onPressed: () => bloc.updateData(doc, description, image, name, price),