Skip to content

[103] Fix filtering 104 starter and 103 complete #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mdc_100_series/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class HomePage extends StatelessWidget {
),
],
),
body: AsymmetricView(products: ProductsRepository.loadProducts()),
body: AsymmetricView(
products: ProductsRepository.loadProducts(Category.all)),
);
}
}
11 changes: 9 additions & 2 deletions mdc_100_series/lib/model/products_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import 'product.dart';

class ProductsRepository {
static List<Product> loadProducts() {
return const [
static List<Product> loadProducts(Category category) {
const allProducts = <Product> [
Product(
category: Category.accessories,
id: 0,
Expand Down Expand Up @@ -284,5 +284,12 @@ class ProductsRepository {
price: 58,
),
];
if (category == Category.all) {
return allProducts;
} else {
return allProducts.where((Product p) {
return p.category == category;
}).toList();
}
}
}