mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
[Shrine] New Shrine with expanding cart bottom sheet from experimenal (#18)
This commit is contained in:
committed by
Andrew Brogdon
parent
b5ce05e934
commit
4b4d5fef9c
@@ -103,7 +103,7 @@ class AppStateModel extends Model {
|
||||
|
||||
// Loads the list of available products from the repo.
|
||||
void loadProducts() {
|
||||
_availableProducts = ProductsRepository.loadProducts();
|
||||
_availableProducts = ProductsRepository.loadProducts(Category.all);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
@@ -284,5 +284,10 @@ class ProductsRepository {
|
||||
price: 58,
|
||||
),
|
||||
];
|
||||
if (category == Category.all) {
|
||||
return allProducts;
|
||||
} else {
|
||||
return allProducts.where((Product p) => p.category == category).toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user