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:
States are an essential part of the Flutter UI framework, used to update the UI as the user interacts with the app. Some states, like the loading and initial states, can be empty since they do not require any information. On the other hand, the complete state usually holds the response from the Bloc, which the UI uses to rebuild the page.
```dart
@immutable
abstractclassCreatePlayerStateextendsEquatable{
...
...
@@ -17,5 +18,6 @@ class CreatePlayerComplete extends CreatePlayerState {
List<Object>getprops=>[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
In the code snippet provided, we have an abstract class called CreatePlayerState and two concrete states: CreatePlayerLoading and CreatePlayerComplete. The Equatable package provides an easy way to define equality comparison methods in Dart. In the CreatePlayerState abstract class, the props method is used to check for instance equality. Instances are considered equal if they are instances of the CreatePlayerState class, and no instance variables are needed to evaluate for equality.
In the CreatePlayerComplete class, there is a single instance variable called response, which is initialized by the constructor. The props list at the end of the class definition is used to determine whether two instances of the CreatePlayerComplete class are equal. In this case, the instances are considered equal if they are instances of the CreatePlayerComplete class and the value of their response instance variable is the same.