1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
thesis_shop/lib/stores/product_list_provider.dart

13 lines
556 B

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:thesis_shop/models/product.dart';
import 'package:thesis_shop/stores/product_loading_provider.dart';
import 'package:thesis_shop/stores/user_store.dart';
final productListProvider = Provider<AsyncValue<List<Product>>>((ref) {
final isSignedIn = ref.watch(userStoreProvider);
if (!isSignedIn) {
return ref.watch(productLoadingProvider);
}
return ref.watch(productLoadingProvider).whenData(
(products) => products.map((pro) => pro.copyWithDiscount()).toList());
});