Skip to content

Commit 78851a0

Browse files
authored
[104] Fix filtering 104 complete (#109)
1 parent fe2f255 commit 78851a0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

mdc_100_series/lib/home.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ class HomePage extends StatelessWidget {
2525

2626
@override
2727
Widget build(BuildContext context) {
28-
return AsymmetricView(products: ProductsRepository.loadProducts());
28+
return AsymmetricView(products: ProductsRepository.loadProducts(category));
2929
}
3030
}

mdc_100_series/lib/model/products_repository.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import 'product.dart';
1616

1717
class ProductsRepository {
18-
static List<Product> loadProducts() {
19-
return const [
18+
static List<Product> loadProducts(Category category) {
19+
const allProducts = <Product> [
2020
Product(
2121
category: Category.accessories,
2222
id: 0,
@@ -284,5 +284,12 @@ class ProductsRepository {
284284
price: 58,
285285
),
286286
];
287+
if (category == Category.all) {
288+
return allProducts;
289+
} else {
290+
return allProducts.where((Product p) {
291+
return p.category == category;
292+
}).toList();
293+
}
287294
}
288295
}

0 commit comments

Comments
 (0)