将项目插入列表视图

时间:2019-11-10 22:45:23

标签: listview flutter insert

我有一个列表视图,其中包含图像,图像标题,图像说明和价格。 我有用于获取这些文本的文本字段,然后在底部添加此图像并在列表视图生成器中添加其他内容。如何在每次按一下botton时仅将单个项目添加到列表视图中?

 Padding(padding: EdgeInsets.only(top: 20.0),
         child: ListView.builder(
           scrollDirection: Axis.vertical,
           itemCount: list.length,
           itemBuilder:(BuildContext context,int index){
              return new Container(
                child: Column(children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.only(right: 20.0,left: 20.0),
                    child:image[index], 
                    //widget.pic,
                  ),                
            Row(
              children: <Widget>[
                Padding(padding: EdgeInsets.only(top: 10.0 ,left: 130.0),    
                child: Text(list[index],style: TextStyle(fontSize: 30.0,fontStyle: FontStyle.italic,
                fontWeight:FontWeight.bold),)),
                  SizedBox(width: 50.0),
                 Container(width: 60.0,
                  margin: EdgeInsets.only(top: 15.0),
                   child: SizedBox(width: 150.0,height: 25.0,
                      child: DecoratedBox(decoration: BoxDecoration(color: Colors.red[700],
                      borderRadius:BorderRadius.circular(5.0) ),
                      child: Text(list2[index],style: TextStyle(fontSize: 20.0,color: Colors.white),)),                
                   ))]),
                  Padding(
                    padding: const EdgeInsets.only(right:150.0),
                    child: Text(list3[index],style: TextStyle(fontSize: 15.0,fontWeight: FontWeight.bold),),
                  ),                    
                ],),                    
              );

0 个答案:

没有答案