1
+ // ignore_for_file: curly_braces_in_flow_control_structures
2
+
1
3
import 'package:cloud_firestore/cloud_firestore.dart' ;
2
4
import 'package:emart/common_widgets/home_buttons.dart' ;
3
5
import 'package:emart/common_widgets/loading_indicator.dart' ;
@@ -152,8 +154,9 @@ class HomeScreen extends StatelessWidget {
152
154
Container (
153
155
width: double .infinity,
154
156
padding: const EdgeInsets .all (12 ),
155
- decoration: const BoxDecoration (
157
+ decoration: BoxDecoration (
156
158
color: redColor,
159
+ borderRadius: BorderRadius .circular (8 ),
157
160
),
158
161
child: Column (
159
162
crossAxisAlignment: CrossAxisAlignment .start,
@@ -166,40 +169,66 @@ class HomeScreen extends StatelessWidget {
166
169
10. heightBox,
167
170
SingleChildScrollView (
168
171
scrollDirection: Axis .horizontal,
169
- child: Row (
170
- children: List .generate (
171
- 6 ,
172
- (index) => Column (
173
- crossAxisAlignment: CrossAxisAlignment .start,
174
- children: [
175
- Image .asset (
176
- imgP1,
177
- width: 130 ,
178
- fit: BoxFit .cover,
172
+ child: FutureBuilder (
173
+ future: FirestoreService .getFeaturedProduct (),
174
+ builder: (BuildContext context,
175
+ AsyncSnapshot <QuerySnapshot > snapshot) {
176
+ if (! snapshot.hasData)
177
+ return loadingIndicator ();
178
+ else if (snapshot.data! .docs.isEmpty)
179
+ return "No Featured Product"
180
+ .text
181
+ .white
182
+ .makeCentered ();
183
+ var featuredData = snapshot.data! .docs;
184
+ return Row (
185
+ children: List .generate (
186
+ featuredData.length,
187
+ (index) => Column (
188
+ crossAxisAlignment:
189
+ CrossAxisAlignment .start,
190
+ children: [
191
+ Image .network (
192
+ featuredData[index]['p_images' ][0 ],
193
+ fit: BoxFit .cover,
194
+ width: 130 ,
195
+ height: 140 ,
196
+ ),
197
+ 10. heightBox,
198
+ "${featuredData [index ]['p_name' ]}"
199
+ .text
200
+ .fontFamily (semibold)
201
+ .color (darkFontGrey)
202
+ .make (),
203
+ 10. heightBox,
204
+ "\$ ${featuredData [index ]['p_price' ]}"
205
+ .text
206
+ .color (redColor)
207
+ .fontFamily (bold)
208
+ .size (16 )
209
+ .make (),
210
+ ],
211
+ )
212
+ .box
213
+ .white
214
+ .roundedSM
215
+ .margin (const EdgeInsets .symmetric (
216
+ horizontal: 4 ))
217
+ .padding (const EdgeInsets .all (8 ))
218
+ .make ()
219
+ .onTap (
220
+ () {
221
+ Get .to (
222
+ () => ItemDetails (
223
+ title: featuredData[index]
224
+ ['p_name' ],
225
+ data: featuredData[index]),
226
+ );
227
+ },
179
228
),
180
- 10. heightBox,
181
- "Laptop 8GB/64GB"
182
- .text
183
- .fontFamily (semibold)
184
- .color (darkFontGrey)
185
- .make (),
186
- 10. heightBox,
187
- "\$ 600"
188
- .text
189
- .color (redColor)
190
- .fontFamily (bold)
191
- .size (16 )
192
- .make (),
193
- ],
194
- )
195
- .box
196
- .white
197
- .roundedSM
198
- .margin (const EdgeInsets .symmetric (
199
- horizontal: 4 ))
200
- .padding (const EdgeInsets .all (8 ))
201
- .make (),
202
- ),
229
+ ),
230
+ );
231
+ },
203
232
),
204
233
),
205
234
],
0 commit comments