item-card.dart 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'package:flutter/material.dart';
  2. import 'package:fooddeliveryapp/constants.dart';
  3. import 'package:fooddeliveryapp/model/product.dart';
  4. class ItemCard extends StatelessWidget {
  5. final Product product;
  6. final Function press;
  7. const ItemCard({
  8. Key key,
  9. this.product,
  10. this.press,
  11. }) : super(key: key);
  12. @override
  13. Widget build(BuildContext context) {
  14. return GestureDetector(
  15. onTap: press,
  16. child: Column(
  17. crossAxisAlignment: CrossAxisAlignment.start,
  18. children: [
  19. Expanded(
  20. child: Container(
  21. padding: EdgeInsets.all(kDefaultPaddin),
  22. // For demo we use fixed height and width
  23. // Now we dont need them
  24. // height: 180,
  25. // width: 160,
  26. decoration: BoxDecoration(
  27. color: product.color,
  28. borderRadius: BorderRadius.circular(16),
  29. ),
  30. child: Hero(
  31. tag: "${product.id}",
  32. child: Image.asset(product.image),
  33. ),
  34. ),
  35. ),
  36. Padding(
  37. padding: const EdgeInsets.symmetric(vertical: kDefaultPaddin / 4),
  38. child: Text(
  39. // products is out demo list
  40. product.title,
  41. style: TextStyle(color: kTextLightColor),
  42. ),
  43. ),
  44. Text(
  45. "${product.price}元",
  46. style: TextStyle(fontWeight: FontWeight.bold),
  47. )
  48. ],
  49. ),
  50. );
  51. }
  52. }