Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

extends class in flutter with "<p1,p2>"

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>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

?

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading