enum Status {
  initial,
  loading,
  success,
  error,
  empty,
}


class Resource<T> {
  final Status status;
  final T? data;
  final String? message;

  const Resource._({
    required this.status,
    this.data,
    this.message,
  });

  const Resource.initial() : this._(status: Status.initial);

  const Resource.loading() : this._(status: Status.loading);

  const Resource.success(T data) : this._(status: Status.success, data: data);

  const Resource.error(String message) : this._(status: Status.error, message: message);

  const Resource.empty() : this._(status: Status.empty);


  bool get isInitial => status == Status.initial;

  bool get isLoading => status == Status.loading;

  bool get isSuccess => status == Status.success;

  bool get isError => status == Status.error;

  bool get isEmpty => status == Status.empty;

  @override
  String toString() {
    return 'Resource{status: $status, data: $data, message: $message}';
  }
}