add_to_cart.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import 'package:flutter/material.dart';
  2. import 'package:fooddeliveryapp/constants.dart';
  3. class AddToCart extends StatelessWidget {
  4. final Function pressButton;
  5. const AddToCart({
  6. Key key,
  7. // @required this.product,
  8. this.count,
  9. this.pressButton,
  10. }) : super(key: key);
  11. // final Product product;
  12. final int count;
  13. @override
  14. Widget build(BuildContext context) {
  15. return Padding(
  16. padding: const EdgeInsets.symmetric(vertical: kDefaultPaddin),
  17. child: Row(
  18. children: [
  19. Expanded(
  20. child: SizedBox(
  21. height: 50,
  22. child: FlatButton(
  23. shape: RoundedRectangleBorder(
  24. borderRadius: BorderRadius.circular(18)),
  25. // color: product.color,
  26. color: Colors.red,
  27. onPressed: () {
  28. ///加入购物车
  29. print("数量:" + count.toString());
  30. pressButton();
  31. },
  32. child: Text(
  33. "结账".toUpperCase(),
  34. style: TextStyle(
  35. fontSize: 17,
  36. fontWeight: FontWeight.bold,
  37. color: Colors.white,
  38. ),
  39. ),
  40. ),
  41. ),
  42. ),
  43. ],
  44. ),
  45. );
  46. }
  47. }