Create States authored by Nicholas Sarian's avatar Nicholas Sarian
States are used by the UI to trigger changes in the page as the user performs actions on the page. Some states, such as the loading and initial state, can be empty as they do not need to have anything in them. The complete state will often contain the response from the Bloc. Below contains the abstract class CreatePlayerState as well as two states, the CreatePlayerLoading and CreatePlayerComplete:
```dart
@immutable
abstract class CreatePlayerState extends Equatable {
@override
List<Object> get props => [];
}
class CreatePlayerLoading extends CreatePlayerState {}
class CreatePlayerComplete extends CreatePlayerState {
final BasicResponse response;
CreatePlayerComplete(this.response);
@override
List<Object> get props => [response];
}
```
`List<Object> get props => [];` are used for comparison for equality. `Equatable` is a package that provides a convenient way for equality comparison methods for Dart.
In the abstract class, classes will be considered equal if they are instances of the CreatePlayerState, and instance variables will not need to be compared for equality. In the CreatePlayerComplete class, it contains a single instance variable called `response` and a constructor. The props at the end means the class will be considered equal if it's an instance of CreatePlayerState and the value of the response instance variable is the same.
\ No newline at end of file