import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:thesis_shop/stores/product_list_provider.dart'; import 'package:thesis_shop/widgets/user_switch.dart'; import 'cart_button_overlay.dart'; import 'product_list.dart'; class ProductListScreen extends ConsumerWidget { const ProductListScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context, ref) { return Scaffold( appBar: AppBar( title: const Text('Thesis Shop'), actions: const [UserSwitch()], ), body: ref.watch(productListProvider).when( data: (products) => CartButtonOverlay( child: ProductList(products: products), ), error: (error, _) => Center(child: Text(error.toString())), loading: () => const Center(child: CircularProgressIndicator()), ), ); } }