product_title_with_image.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'package:flutter/material.dart';
  2. import 'package:fooddeliveryapp/constants.dart';
  3. import 'package:fooddeliveryapp/model/product.dart';
  4. class ProductTitleWithImage extends StatelessWidget {
  5. const ProductTitleWithImage({
  6. Key key,
  7. @required this.product,
  8. }) : super(key: key);
  9. final Product product;
  10. @override
  11. Widget build(BuildContext context) {
  12. return Padding(
  13. padding: const EdgeInsets.symmetric(horizontal: kDefaultPaddin),
  14. child: Column(
  15. crossAxisAlignment: CrossAxisAlignment.start,
  16. children: [
  17. Text(
  18. "最最美味的菜品来自海底捞",
  19. style: TextStyle(color: Colors.white),
  20. ),
  21. Text(
  22. product.title,
  23. style: Theme.of(context)
  24. .textTheme
  25. .headline4
  26. .copyWith(color: Colors.white, fontWeight: FontWeight.bold),
  27. ),
  28. SizedBox(height: kDefaultPaddin),
  29. Row(
  30. children: [
  31. RichText(
  32. text: TextSpan(
  33. children: [
  34. TextSpan(text: "价格\n"),
  35. TextSpan(
  36. text: "${product.price}元",
  37. style: Theme.of(context).textTheme.headline4.copyWith(
  38. color: Colors.white, fontWeight: FontWeight.bold),
  39. ),
  40. ],
  41. ),
  42. ),
  43. SizedBox(width: kDefaultPaddin),
  44. Expanded(
  45. child: Hero(
  46. tag: "${product.id}",
  47. child: Image.asset(
  48. product.image,
  49. fit: BoxFit.fill,
  50. ),
  51. ),
  52. )
  53. ],
  54. )
  55. ],
  56. ),
  57. );
  58. }
  59. }