toDataState method

DataState<T> toDataState()

Converts this ApiResult to a DataState.

Implementation

DataState<T> toDataState() => switch (this) {
      ApiSuccess<T>(:final T data)
          when data == null || (data is List && data.isEmpty) =>
        DataEmpty<T>(),
      ApiSuccess<T>(:final T data) => DataLoaded<T>(data),
      ApiError<T>(:final GeneralResponse response) =>
        DataError<T>(hint: response.message),
      ApiFailure<T>(:final DioException exception) =>
        DataError<T>(hint: exception.message),
    };