carrito_screen.dart 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import 'package:flutter/material.dart';
  2. const List<Map<String, dynamic>> items = [
  3. {
  4. 'nombre': 'Hamburguesa de res',
  5. 'descripcion': 'Hamburguesa de res con queso cheddar',
  6. 'precio': '\$ 120.00',
  7. 'imageUrl':
  8. 'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
  9. },
  10. {
  11. 'nombre': 'Hamburguesa de pollo',
  12. 'descripcion': 'Hamburguesa de pollo con queso cheddar',
  13. 'precio': '\$ 100.00',
  14. 'imageUrl':
  15. 'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
  16. },
  17. ];
  18. class CarritoScreen extends StatefulWidget {
  19. const CarritoScreen({super.key});
  20. @override
  21. State<CarritoScreen> createState() => _CarritoScreenState();
  22. }
  23. class _CarritoScreenState extends State<CarritoScreen> {
  24. @override
  25. Widget build(BuildContext context) {
  26. return Scaffold(
  27. backgroundColor: Colors.white,
  28. appBar: AppBar(
  29. title: const Row(
  30. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  31. children: [
  32. Text('Atrás'),
  33. Column(
  34. crossAxisAlignment: CrossAxisAlignment.start,
  35. children: [
  36. Text(
  37. 'Su carrito',
  38. style: TextStyle(
  39. fontStyle: FontStyle.italic,
  40. fontSize: 16,
  41. color: Colors.black54),
  42. ),
  43. Text(
  44. 'Total: \$0.00',
  45. style: TextStyle(
  46. fontWeight: FontWeight.bold,
  47. fontSize: 20,
  48. ),
  49. ),
  50. ],
  51. ),
  52. ],
  53. ),
  54. ),
  55. body: ListView.builder(
  56. itemBuilder: (context, index) {
  57. final item = items[index];
  58. return _buildInfoItem(item['nombre'], item['descripcion'],
  59. item['precio'], item['imageUrl']);
  60. },
  61. itemCount: items.length),
  62. );
  63. }
  64. }
  65. _buildInfoItem(String title, String subtitle, String precio, String imageUrl) {
  66. return Container(
  67. height: 90,
  68. width: double.infinity,
  69. color: Colors.white,
  70. padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
  71. child: Row(
  72. children: [
  73. // Leading image
  74. Container(
  75. width: 80,
  76. height: 80,
  77. child: ClipRRect(
  78. borderRadius: BorderRadius.circular(4),
  79. child: Image.network(
  80. imageUrl,
  81. fit: BoxFit.cover,
  82. ),
  83. ),
  84. ),
  85. SizedBox(width: 16),
  86. // Title and subtitle
  87. Expanded(
  88. child: Column(
  89. crossAxisAlignment: CrossAxisAlignment.start,
  90. mainAxisAlignment: MainAxisAlignment.center,
  91. children: [
  92. Text(
  93. title,
  94. style: TextStyle(
  95. color: Colors.black,
  96. fontSize: 16,
  97. fontWeight: FontWeight.bold,
  98. ),
  99. ),
  100. SizedBox(height: 4),
  101. Text(
  102. 'MXN $precio',
  103. style: TextStyle(
  104. color: Colors.black,
  105. fontSize: 18,
  106. fontWeight: FontWeight.bold,
  107. ),
  108. ),
  109. ],
  110. ),
  111. ),
  112. // Quantity controls
  113. Row(
  114. children: [
  115. Container(
  116. width: 40,
  117. height: 40,
  118. alignment: Alignment.center,
  119. child: Icon(
  120. Icons.remove,
  121. color: Colors.black,
  122. size: 24,
  123. ),
  124. ),
  125. Container(
  126. width: 40,
  127. alignment: Alignment.center,
  128. child: Text(
  129. subtitle,
  130. style: TextStyle(
  131. color: Colors.black,
  132. fontSize: 20,
  133. fontWeight: FontWeight.bold,
  134. ),
  135. ),
  136. ),
  137. Container(
  138. width: 40,
  139. height: 40,
  140. alignment: Alignment.center,
  141. child: Icon(
  142. Icons.add,
  143. color: Colors.red,
  144. size: 24,
  145. ),
  146. ),
  147. ],
  148. ),
  149. ],
  150. ),
  151. );
  152. }