Update States authored by Nicholas Sarian's avatar Nicholas Sarian
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. 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.
Here are the states for creating a new player:
```dart ```dart
@immutable @immutable
abstract class CreatePlayerState extends Equatable { abstract class CreatePlayerState extends Equatable {
@override @override
List<Object> get props => []; List<Object> get props => [];
} }
class CreatePlayerInitial extends CreatePlayerState {}
class CreatePlayerLoading extends CreatePlayerState {} class CreatePlayerLoading extends CreatePlayerState {}
class CreatePlayerComplete extends CreatePlayerState { class CreatePlayerComplete extends CreatePlayerState {
...@@ -18,6 +22,6 @@ class CreatePlayerComplete extends CreatePlayerState { ...@@ -18,6 +22,6 @@ class CreatePlayerComplete extends CreatePlayerState {
List<Object> get props => [response]; List<Object> get props => [response];
} }
``` ```
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 code snippet above, 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. 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.
\ No newline at end of file