Skip to content

Commit

Permalink
Merge pull request #2942 from MuhammamdArslanKhan/format-files
Browse files Browse the repository at this point in the history
style: format code
  • Loading branch information
jonataslaw authored Nov 2, 2023
2 parents 359e831 + ce6d4ef commit 499b4a2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/get_state_manager/src/rx_flutter/rx_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,15 @@ typedef NotifierBuilder<T> = Widget Function(T state);

abstract class GetStatus<T> with Equality {
const GetStatus();

factory GetStatus.loading() => LoadingStatus<T>();

factory GetStatus.error(String message) => ErrorStatus<T, String>(message);

factory GetStatus.empty() => EmptyStatus<T>();

factory GetStatus.success(T data) => SuccessStatus<T>(data);

factory GetStatus.custom() => CustomStatus<T>();
}

Expand All @@ -266,6 +271,7 @@ class LoadingStatus<T> extends GetStatus<T> {

class SuccessStatus<T> extends GetStatus<T> {
final T data;

const SuccessStatus(this.data);

@override
Expand All @@ -274,6 +280,7 @@ class SuccessStatus<T> extends GetStatus<T> {

class ErrorStatus<T, S> extends GetStatus<T> {
final S? error;

const ErrorStatus([this.error]);

@override
Expand All @@ -287,10 +294,15 @@ class EmptyStatus<T> extends GetStatus<T> {

extension StatusDataExt<T> on GetStatus<T> {
bool get isLoading => this is LoadingStatus;

bool get isSuccess => this is SuccessStatus;

bool get isError => this is ErrorStatus;

bool get isEmpty => this is EmptyStatus;

bool get isCustom => !isLoading && !isSuccess && !isError && !isEmpty;

String get errorMessage {
final isError = this is ErrorStatus;
if (isError) {
Expand Down

0 comments on commit 499b4a2

Please sign in to comment.