Advertisement
Hitesh_jadhav

shopapp_cart_product

Feb 24th, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3.  
  4. class cart_prod extends StatefulWidget {
  5. const cart_prod({Key? key}) : super(key: key);
  6.  
  7. @override
  8. _cart_prodState createState() => _cart_prodState();
  9. }
  10.  
  11. class _cart_prodState extends State<cart_prod> {
  12. var prod_on_cart = [
  13. {
  14. "name": "Blazzer",
  15. "picture": "images/products/blazer1.jpeg",
  16. "old_price": 100,
  17. "price": 85,
  18. "size": "M",
  19. "color": "Black",
  20. "quantity": 2,
  21. },
  22. {
  23. "name": "Red dress",
  24. "picture": "images/products/dress1.jpeg",
  25. "old_price": 200,
  26. "price": 100,
  27. "size": "xxl",
  28. "color": "Red",
  29. "quantity": 2,
  30. },
  31. {
  32. "name": "Blazzer",
  33. "picture": "images/products/blazer2.jpeg",
  34. "old_price": 100,
  35. "price": 85,
  36. "size": "M",
  37. "color": "Black",
  38. "quantity": 2,
  39. },
  40. {
  41. "name": "Red dress",
  42. "picture": "images/products/dress2.jpeg",
  43. "old_price": 200,
  44. "price": 100,
  45. "size": "xl",
  46. "color": "Red",
  47. "quantity": 2,
  48. },
  49. {
  50. "name": "Blazzer",
  51. "picture": "images/products/hills1.jpeg",
  52. "old_price": 100,
  53. "price": 85,
  54. "size": "9",
  55. "color": "Black2",
  56. "quantity": 2,
  57. },
  58. {
  59. "name": "Red dress",
  60. "picture": "images/products/hills2.jpeg",
  61. "old_price": 200,
  62. "price": 100,
  63. "size": "10",
  64. "color": "Red",
  65. "quantity": 2,
  66. },
  67. ];
  68.  
  69. @override
  70. Widget build(BuildContext context) {
  71. return ListView.builder(
  72. itemCount: prod_on_cart.length,
  73. itemBuilder: (context, index) => single_cart_product(
  74. cart_prod_name: prod_on_cart[index]["name"],
  75. cart_prod_color: prod_on_cart[index]["color"],
  76. cart_prod_size: prod_on_cart[index]["size"],
  77. cart_prod_qty: prod_on_cart[index]["quantity"],
  78. cart_prod_price: prod_on_cart[index]["price"],
  79. cart_prod_picture: prod_on_cart[index]["picture"],
  80. ));
  81. }
  82. }
  83.  
  84. class single_cart_product extends StatelessWidget {
  85. final cart_prod_name;
  86. final cart_prod_price;
  87. final cart_prod_picture;
  88. final cart_prod_qty;
  89. final cart_prod_color;
  90. final cart_prod_size;
  91.  
  92. const single_cart_product(
  93. {this.cart_prod_name,
  94. this.cart_prod_price,
  95. this.cart_prod_picture,
  96. this.cart_prod_qty,
  97. this.cart_prod_color,
  98. this.cart_prod_size});
  99.  
  100. @override
  101. Widget build(BuildContext context) {
  102. return Card(
  103. child: ListTile(
  104. leading: Image.asset(
  105. cart_prod_picture,
  106. height: 60,
  107. width: 60,
  108. ),
  109. title: Text(cart_prod_name),
  110. subtitle: Column(
  111. children: <Widget>[
  112. Row(
  113. children: <Widget>[
  114. Padding(
  115. padding: EdgeInsets.fromLTRB(0, 8, 8, 8),
  116. child: Text("Size")),
  117. Padding(
  118. padding: EdgeInsets.all(8), child: Text(cart_prod_size)),
  119. Padding(
  120. padding: EdgeInsets.fromLTRB(30, 8, 8, 8),
  121. child: Text("Color:"),
  122. ),
  123. Padding(
  124. padding: EdgeInsets.all(4),
  125. child: Text(
  126. cart_prod_color,
  127. style: TextStyle(color: Colors.red),
  128. ),
  129. ),
  130. // Padding(
  131. // padding: EdgeInsets.fromLTRB(20, 8, 8, 8),
  132. // child: Text("Price:"),
  133. // ),
  134. // Padding(
  135. // padding: EdgeInsets.all(4),
  136. // child: Text(
  137. // "${cart_prod_price}",
  138. // style: TextStyle(color: Colors.grey),
  139. // ),
  140. // ),
  141. ],
  142. ),
  143. Container(
  144. alignment: Alignment.topLeft,
  145. child: Text(
  146. "\$${cart_prod_price}",
  147. style: TextStyle(
  148. fontSize: 16,
  149. fontWeight: FontWeight.bold,
  150. color: Colors.red),
  151. ),
  152. )
  153. ],
  154. ),
  155. trailing: Column(
  156. children: <Widget>[
  157. IconButton(onPressed: () {}, icon: Icon(Icons.arrow_drop_up)),
  158. IconButton(onPressed: () {}, icon: Icon(Icons.arrow_drop_down))
  159. ],
  160. ),
  161. ),
  162. );
  163. }
  164. }
  165.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement