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/bloc/product_bloc_states.dart

31 lines
867 B

part of 'product_bloc.dart';
abstract class ProductsState {
const ProductsState._();
factory ProductsState.loading() => const ProductsLoading();
factory ProductsState.error(String errorMessage) =>
ProductsError(errorMessage);
factory ProductsState.loaded(List<Product> products) =>
ProductsLoaded(products);
bool isLoading() => this is ProductsLoading;
bool isLoaded() => this is ProductsLoaded;
bool hasError() => this is ProductsError;
T as<T extends ProductsState>() => this as T;
}
class ProductsLoading extends ProductsState {
const ProductsLoading() : super._();
}
class ProductsError extends ProductsState {
final String errorMessage;
const ProductsError(this.errorMessage) : super._();
}
class ProductsLoaded extends ProductsState {
final List<Product> products;
const ProductsLoaded(this.products) : super._();
}