Skip to content

Instantly share code, notes, and snippets.

@diefferson
Created September 3, 2021 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diefferson/3d9be1a1c40beefc8e956bf94b4795e2 to your computer and use it in GitHub Desktop.
Save diefferson/3d9be1a1c40beefc8e956bf94b4795e2 to your computer and use it in GitHub Desktop.
BaseState Flutter
class BaseState {
BaseState._();
factory BaseState.success(dynamic data) = SuccessState;
factory BaseState.error(NoodleException error) = ErrorState;
factory BaseState.loading() = LoadingState;
factory BaseState.done() = DoneState;
}
class ErrorState extends BaseState {
ErrorState(this.error) : super._();
final NoodleException error;
}
class LoadingState extends BaseState {
LoadingState() : super._();
}
class DoneState extends BaseState {
DoneState() : super._();
}
class SuccessState extends BaseState {
SuccessState(this.data) : super._();
final dynamic data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment