Reputation: 35
I"m new to flutter and I"m trying to understand the following class extends:
class LoginBloc extends Bloc<LoginEvent, LoginState> {LoginBloc() : super(LoginState());
What does it mean extends Bloc<LoginEvent, LoginState>
?
Upvotes: 2
Views: 276
Reputation: 108
In flutter, the extends
keyword is used to inherit from other classes. In this particular case your LoginBloc
class is inheriting from the Bloc
class.
The Bloc
class takes two dynamic types when it is defined; an Event class and a State class. Flutter/Dart convention is to type everything that you can. The Bloc<LoginEvent, LoginState>
is defining that LoginEvent
is the blocs Event class and LoginState
is the blocs State class.
You will use these two classes to control the state changes in your code. LoginEvents emitted from the front end will trigger functions in the LoginBloc which will then emit different LoginStates which you can listen for on the front end.
Upvotes: 1