enum LoadStatus { idle, loading, data, empty, error } class LoadState { final LoadStatus status; final T data; final String? errorMessage; const LoadState.idle(this.data) : status = LoadStatus.idle, errorMessage = null; const LoadState.loading(this.data) : status = LoadStatus.loading, errorMessage = null; const LoadState.data(this.data) : status = LoadStatus.data, errorMessage = null; const LoadState.empty(this.data) : status = LoadStatus.empty, errorMessage = null; const LoadState.error(this.data, this.errorMessage) : status = LoadStatus.error; bool get isIdle => status == LoadStatus.idle; bool get isLoading => status == LoadStatus.loading; bool get hasError => status == LoadStatus.error; bool get isEmpty => status == LoadStatus.empty; }