I want to pass quantity from listview using a textfield in listtile.
padding: EdgeInsets.all(8.0),
itemCount: allProducts.length,
itemBuilder: (context, index) {
return Consumer<CartModel>(builder: (context, cart, child) {
return Card(
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
allProducts[index].title,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
Container(
width: 30,
child: TextField(
controller: TextEditingController(),
decoration: InputDecoration(
hintText: 'Quantity'
),
),
),
// Text("\$" + allProducts[index].price.toString()),
RaisedButton(
color: Colors.blue[200],
child: Text('Add'),
onPressed: () {
cart.addProduct(allProducts[index]);
},
),
],
),
);
});
},
),
But when I define controller for textfield, it reflects on all of the fields of the listview. Is there any way I can enter custom quantity on individual textfields of the list and pass them to cart?