Bloc: what happen in part of code as List props = const []?

Created on 14 May 2019  路  1Comment  路  Source: felangel/bloc

I dont understand me what happen in this part of code

AuthenticationEvent([List props = const []]) : super(props);

cold you help me to know about that?
thanks

question

Most helpful comment

Hi @MahdiPishguy 馃憢
Thanks for opening an issue!

Regarding your question, since AuthenticationEvent extends Equatable it needs to pass the properties to the superclass.

Equatable uses these properties to override == and hashCode in order to allow you to compare different instances of the same type. You can read more about equatable here.

With that in mind, all this line is doing is making it so you can extend AuthenticationEvent and pass custom properties to the super class (AuthenticationEvent) which will then pass them to the Equatable super class.

class SomeEvent extends AuthenticationEvent {
  final String someProperty;
  final String someOtherProperty;

  SomeEvent(this.someProperty, this.someOtherProperty)
    : super([someProperty, someOtherProperty]);
}

This would not be possible without the line you are referencing.

Hope that makes sense 馃憤

>All comments

Hi @MahdiPishguy 馃憢
Thanks for opening an issue!

Regarding your question, since AuthenticationEvent extends Equatable it needs to pass the properties to the superclass.

Equatable uses these properties to override == and hashCode in order to allow you to compare different instances of the same type. You can read more about equatable here.

With that in mind, all this line is doing is making it so you can extend AuthenticationEvent and pass custom properties to the super class (AuthenticationEvent) which will then pass them to the Equatable super class.

class SomeEvent extends AuthenticationEvent {
  final String someProperty;
  final String someOtherProperty;

  SomeEvent(this.someProperty, this.someOtherProperty)
    : super([someProperty, someOtherProperty]);
}

This would not be possible without the line you are referencing.

Hope that makes sense 馃憤

Was this page helpful?
0 / 5 - 0 ratings