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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user