I have a Flutter project that scans barcodes and move the name and barcode and expiration date by the button to the row on another page and this works as expected. But I'm trying to display this row in my home page that contains a ListView
and I let inside it some empty list I defined above on the same page.
My question: How can I add the row that contains the name, barcode, and date to the list on my home page when I press the button?
This is the button code:
ElevatedButton(
onPressed: () {
final list = [item_Name.text, item_Barcode.text, date.text];
Provider.of<DataListProvider>(context, listen: false).setData(list);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Details_Item(
name: item_Name.text,
barcode: item_Barcode.text,
dateexpair: date.text,
),
),
);
},
and this is the row page :
class Details_Item extends StatelessWidget {
late String name, barcode;
String dateexpair;
Details_Item(
{required this.name, required this.barcode, required this.dateexpair});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${name}',
style: TextStyle(fontSize: 13),
),
SizedBox(
width: 70,
),
Text(
'${barcode}',
style: TextStyle(fontSize: 13),
),
SizedBox(
width: 70,
),
Text(
'${dateexpair}',
style: TextStyle(fontSize: 13),
),
],
);
}
}
my home page code :
child: ListView(
children: Container_items,