Create a MenuItem.dart file with a MenuItem
stateless widget that will serve as a product preview first.
ProductItem (Dummy)
class MenuItem extends StatelessWidget {
final Product product;
final Function onAdd;
const MenuItem({Key? key, required this.product, required this.onAdd})
: super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(4.0),
child: Card(
elevation: 4,
child: Column(
children: [
Image.asset("images/black_coffee.png"),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SelectableText(
product.name,
style: const TextStyle(fontWeight: FontWeight.bold),
),
Text("\$${product.price.toStringAsFixed(2)} ea"),
],
),
ElevatedButton(
onPressed: () {
onAdd(product);
},
child: const Text("Add"))
],
),
),
],
),
),
);
}
}
Now, try to use this Widget in MenuPage
and make MenuPage
the visible Widget when the menu section is selected in the bottom navigation bar.