1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00

Fixing unchangeable Shrine categories. (#9)

This commit is contained in:
Andrew Brogdon
2018-08-08 08:41:18 -07:00
committed by GitHub
parent 2681473884
commit 370a72caa5
5 changed files with 48 additions and 68 deletions

View File

@@ -60,7 +60,9 @@ class AppStateModel extends Model {
if (_selectedCategory == Category.all) {
return List.from(_availableProducts);
} else {
return _availableProducts.where((p) => p.category == _selectedCategory);
return _availableProducts
.where((p) => p.category == _selectedCategory)
.toList();
}
}
@@ -104,4 +106,9 @@ class AppStateModel extends Model {
_availableProducts = ProductsRepository.loadProducts();
notifyListeners();
}
void setCategory(Category newCategory) {
_selectedCategory = newCategory;
notifyListeners();
}
}