Adding Products Tile
Inside the product_screen.dart file under src/product/view/products/ add the following code:
class _ProductItem extends StatelessWidget {
final Product product;
const _ProductItem({Key key, @required this.product})
: assert(product != null),
super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => context.navigator.push(
Routes.productScreen,
arguments: ProductScreenArguments(product: product),
),
child: Card(
margin: EdgeInsets.zero,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Container(
color: Colors.white,
padding: const EdgeInsets.all(8),
child: Image.network(product.image),
),
),
Container(
height: 48,
color: Colors.grey[200],
padding: const EdgeInsets.all(4),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
product.title,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontWeight: FontWeight.w600),
),
const SizedBox(height: 4),
Text('${product.price} ETB'),
],
),
),
),
IconButton(
onPressed: () =>
context.read<CartCubit>().addProduct(product),
icon: const Icon(Icons.add_shopping_cart_rounded),
),
],
),
),
],
),
),
);
}
}
Last updated