Firebase 如何在一个列表的特定索引处进行更改,该列表的数据是在Flatter中从cloud Firestore获取的?

Firebase 如何在一个列表的特定索引处进行更改,该列表的数据是在Flatter中从cloud Firestore获取的?,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,在我的Flatter应用程序中,我从Firestore获取了一个列表中的数据,现在想添加或删除一个选项,用于增加或减少列表中特定项目的单位数,但经过多次尝试后,由于整个列表中的计数得到更新,而不是索引中的特定元素,因此无法做到这一点。有人能帮我吗 CustomScrollView( physics: BouncingScrollPhysics(), slivers: <Widget>[

在我的Flatter应用程序中,我从Firestore获取了一个列表中的数据,现在想添加或删除一个选项,用于增加或减少列表中特定项目的单位数,但经过多次尝试后,由于整个列表中的计数得到更新,而不是索引中的特定元素,因此无法做到这一点。有人能帮我吗

CustomScrollView(
                physics: BouncingScrollPhysics(),
                slivers: <Widget>[
                  SliverList(
                    delegate: SliverChildBuilderDelegate((context, index){
                      return Container(
                  margin: EdgeInsets.only(top: 15.0,left: 15.0,right: 15.0),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Container(
                        child: Text(snapshot.data.documents[index].documentID,style: TextStyle(fontFamily: "DelishN", fontSize: 15.0),),
                      ),
                      Container(
                        decoration: BoxDecoration(
                          border: Border.all(
                            width: 2.0,
                            color: Colors.black
                          ),
                          borderRadius: BorderRadius.circular(23.0)
                        ),
                        child: Row(
                          children: <Widget>[
                            FloatingActionButton(
                              onPressed: (){
                                add();
                              },
                              mini: true,
                              child: Icon(Icons.add, color: Colors.black,),
                              backgroundColor: Colors.white,
                            ),
                            SizedBox(
                              width: 7.0,
                            ),
                            Text(_n.toString(), style: TextStyle(fontFamily: 'DelishN',),),
                            SizedBox(
                              width: 7.0,
                            ),
                            FloatingActionButton(
                              onPressed: (){
                                minus();
                              },
                              mini: true,
                              child: Icon(Icons.remove, color: Colors.black,),
                              backgroundColor: Colors.white,)
                          ],
                        ),
                      )
                    ],
                  )
            );
                    },
                    childCount: snapshot.data.documents.length))],
              )
CustomScrollView(
物理:弹跳CrollPhysics(),
条子:[
银表(
委托:SliverChildBuilderDelegate((上下文,索引){
返回容器(
边距:仅限边集(顶部:15.0,左侧:15.0,右侧:15.0),
孩子:排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
容器(
子项:文本(snapshot.data.documents[index].documentID,样式:TextStyle(fontFamily:“DelishN”,fontSize:15.0),
),
容器(
装饰:盒子装饰(
边界:边界(
宽度:2.0,
颜色:颜色。黑色
),
边界半径:边界半径。圆形(23.0)
),
孩子:排(
儿童:[
浮动操作按钮(
已按下:(){
添加();
},
米尼:是的,
子:图标(Icons.add,颜色:Colors.black,),
背景颜色:Colors.white,
),
大小盒子(
宽度:7.0,
),
Text(_n.toString(),样式:TextStyle(fontFamily:'DelishN',),),
大小盒子(
宽度:7.0,
),
浮动操作按钮(
已按下:(){
负();
},
米尼:是的,
子:图标(Icons.remove,颜色:Colors.black,),
背景颜色:颜色。白色,)
],
),
)
],
)
);
},
childCount:snapshot.data.documents.length)),
)

您能否分享足够多的代码以使其可复制,您可以查看提供一些代码片段所需的指导原则,兄弟……是的,我添加了代码片段…您的问题是关于在应用程序中添加/删除,还是关于以后如何编辑firestore上的值?关于在列表中添加/删除按钮,该按钮将增加/减少该特定项目的单位数,而不是列表中所有项目的单位数。