12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import 'package:flutter/material.dart';
- import 'package:fooddeliveryapp/model/constants.dart';
- import 'package:fooddeliveryapp/model/product.dart';
- class ItemCard extends StatelessWidget {
- final Product? product;
- final Function? press;
- const ItemCard({
- Key? key,
- this.product,
- this.press,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: press as void Function()?,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Expanded(
- child: Container(
- padding: EdgeInsets.all(kDefaultPaddin),
- // For demo we use fixed height and width
- // Now we dont need them
- // height: 180,
- // width: 160,
- decoration: BoxDecoration(
- color: product!.color,
- borderRadius: BorderRadius.circular(16),
- ),
- child: Hero(
- tag: "${product!.id}",
- child: Image.asset(product!.image!),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(vertical: kDefaultPaddin / 4),
- child: Text(
- // products is out demo list
- product!.title!,
- style: TextStyle(color: kTextLightColor),
- ),
- ),
- Text(
- "${product!.price}元",
- style: TextStyle(fontWeight: FontWeight.bold),
- )
- ],
- ),
- );
- }
- }
|