Advertisement
rafisbr

card_cart.dart

Jul 13th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:provider/provider.dart';
  3. import 'package:shamo/models/cart_model.dart';
  4. import 'package:shamo/providers/cart_provider.dart';
  5. import 'package:shamo/theme.dart';
  6.  
  7. class CartCard extends StatelessWidget {
  8. final CartModel cart;
  9. CartCard(this.cart);
  10.  
  11. @override
  12. Widget build(BuildContext context) {
  13. CartProvider cartProvider = Provider.of<CartProvider>(context);
  14.  
  15. return Container(
  16. margin: EdgeInsets.only(
  17. top: defaultMargin,
  18. ),
  19. padding: EdgeInsets.symmetric(
  20. horizontal: 16,
  21. vertical: 10,
  22. ),
  23. decoration: BoxDecoration(
  24. color: backgroundColor4,
  25. borderRadius: BorderRadius.circular(12),
  26. ),
  27. child: Column(
  28. children: [
  29. Row(
  30. children: [
  31. Container(
  32. width: 60,
  33. height: 60,
  34. decoration: BoxDecoration(
  35. borderRadius: BorderRadius.circular(12),
  36. image: DecorationImage(
  37. image: NetworkImage(
  38. cart.product.galleries[0].url,
  39. ),
  40. ),
  41. ),
  42. ),
  43. SizedBox(
  44. width: 12,
  45. ),
  46. Expanded(
  47. child: Column(
  48. crossAxisAlignment: CrossAxisAlignment.start,
  49. children: [
  50. Text(
  51. cart.product.name,
  52. style: primaryTextStyle.copyWith(
  53. fontWeight: semibold,
  54. ),
  55. ),
  56. Text(
  57. '\$${cart.product.price}',
  58. style: priceTextStyle,
  59. ),
  60. ],
  61. ),
  62. ),
  63. Column(
  64. children: [
  65. GestureDetector(
  66. onTap: () {
  67. cartProvider.addQuantity(cart.id);
  68. },
  69. child: Image.asset(
  70. 'assets/button_add.png',
  71. width: 16,
  72. ),
  73. ),
  74. SizedBox(
  75. height: 2,
  76. ),
  77. Text(
  78. cart.quantity.toString(),
  79. style: primaryTextStyle.copyWith(
  80. fontWeight: medium,
  81. ),
  82. ),
  83. SizedBox(
  84. height: 2,
  85. ),
  86. GestureDetector(
  87. onTap: () {
  88. cartProvider.reduceQuantity(cart.id);
  89. },
  90. child: Image.asset(
  91. 'assets/button_min.png',
  92. width: 16,
  93. ),
  94. ),
  95. ],
  96. ),
  97. ],
  98. ),
  99. SizedBox(
  100. height: 12,
  101. ),
  102. GestureDetector(
  103. onTap: () {
  104. cartProvider.removeCart(cart.id);
  105. },
  106. child: Row(
  107. children: [
  108. Image.asset(
  109. 'assets/icon_remove.png',
  110. width: 10,
  111. ),
  112. SizedBox(
  113. width: 4,
  114. ),
  115. Text(
  116. 'Remove',
  117. style: alertTextStyle.copyWith(
  118. fontSize: 12,
  119. fontWeight: light,
  120. ),
  121. ),
  122. ],
  123. ),
  124. ),
  125. ],
  126. ),
  127. );
  128. }
  129. }
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement