File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,6 @@ class HomePage extends StatelessWidget {
25
25
26
26
@override
27
27
Widget build (BuildContext context) {
28
- return AsymmetricView (products: ProductsRepository .loadProducts ());
28
+ return AsymmetricView (products: ProductsRepository .loadProducts (category ));
29
29
}
30
30
}
Original file line number Diff line number Diff line change 15
15
import 'product.dart' ;
16
16
17
17
class ProductsRepository {
18
- static List <Product > loadProducts () {
19
- return const [
18
+ static List <Product > loadProducts (Category category ) {
19
+ const allProducts = < Product > [
20
20
Product (
21
21
category: Category .accessories,
22
22
id: 0 ,
@@ -284,5 +284,12 @@ class ProductsRepository {
284
284
price: 58 ,
285
285
),
286
286
];
287
+ if (category == Category .all) {
288
+ return allProducts;
289
+ } else {
290
+ return allProducts.where ((Product p) {
291
+ return p.category == category;
292
+ }).toList ();
293
+ }
287
294
}
288
295
}
You can’t perform that action at this time.
0 commit comments