add_to_cart.dart 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_svg/flutter_svg.dart';
  3. import 'package:fooddeliveryapp/constants.dart';
  4. class AddToCart extends StatelessWidget {
  5. final Function pressButton;
  6. const AddToCart({
  7. Key key,
  8. // @required this.product,
  9. this.count,
  10. this.pressButton,
  11. }) : super(key: key);
  12. // final Product product;
  13. final int count;
  14. @override
  15. Widget build(BuildContext context) {
  16. return Padding(
  17. padding: const EdgeInsets.symmetric(vertical: kDefaultPaddin),
  18. child: Row(
  19. children: <Widget>[
  20. Container(
  21. margin: EdgeInsets.only(right: kDefaultPaddin),
  22. height: 50,
  23. width: 58,
  24. decoration: BoxDecoration(
  25. borderRadius: BorderRadius.circular(18),
  26. border: Border.all(
  27. // color: product.color,
  28. color: Colors.red,
  29. ),
  30. ),
  31. child: IconButton(
  32. icon: SvgPicture.asset(
  33. "assets/icons/add_to_cart.svg",
  34. // color: product.color,
  35. color: Colors.red,
  36. ),
  37. onPressed: () {},
  38. ),
  39. ),
  40. Expanded(
  41. child: SizedBox(
  42. height: 50,
  43. child: FlatButton(
  44. shape: RoundedRectangleBorder(
  45. borderRadius: BorderRadius.circular(18)),
  46. // color: product.color,
  47. color: Colors.red,
  48. onPressed: () {
  49. ///加入购物车
  50. print("数量:" + count.toString());
  51. pressButton();
  52. },
  53. child: Text(
  54. "结账".toUpperCase(),
  55. style: TextStyle(
  56. fontSize: 17,
  57. fontWeight: FontWeight.bold,
  58. color: Colors.white,
  59. ),
  60. ),
  61. ),
  62. ),
  63. ),
  64. ],
  65. ),
  66. );
  67. }
  68. }