Created
November 9, 2022 17:29
-
-
Save aniekan12/cf0b2228b6103b1fd4bf9c2508d9ab14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShoppingHomeBloc extends Bloc<ShoppingHomeEvent, ShoppingHomeState> { | |
ShoppingHomeBloc() : super(ShoppingHomeInitial()) { | |
final ShoppingHomeRepository shoppingHomeRepository = | |
ShoppingHomeRepository(); | |
on<GetShoppingItems>((event, emit) async { | |
try { | |
emit(ShoppingHomeLoading()); | |
final shoppingItems = await shoppingHomeRepository.getShoppingItems(); | |
emit(ShoppingHomeLoaded(shoppingHomeModel: shoppingItems)); | |
} catch (e) { | |
emit(ShoppingHomeError(message: e.toString())); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment