moved reload actions out of error context

This commit is contained in:
2024-05-11 17:52:53 +02:00
parent 9fa711e460
commit 181682a424
14 changed files with 129 additions and 93 deletions

View File

@ -18,6 +18,7 @@ final _privateConstructorUsedError = UnsupportedError(
mixin _$LoadableState<TState> {
bool get isLoading => throw _privateConstructorUsedError;
TState? get data => throw _privateConstructorUsedError;
void Function()? get reFetch => throw _privateConstructorUsedError;
LoadingError? get error => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@ -31,7 +32,11 @@ abstract class $LoadableStateCopyWith<TState, $Res> {
$Res Function(LoadableState<TState>) then) =
_$LoadableStateCopyWithImpl<TState, $Res, LoadableState<TState>>;
@useResult
$Res call({bool isLoading, TState? data, LoadingError? error});
$Res call(
{bool isLoading,
TState? data,
void Function()? reFetch,
LoadingError? error});
$LoadingErrorCopyWith<$Res>? get error;
}
@ -52,6 +57,7 @@ class _$LoadableStateCopyWithImpl<TState, $Res,
$Res call({
Object? isLoading = null,
Object? data = freezed,
Object? reFetch = freezed,
Object? error = freezed,
}) {
return _then(_value.copyWith(
@ -63,6 +69,10 @@ class _$LoadableStateCopyWithImpl<TState, $Res,
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as TState?,
reFetch: freezed == reFetch
? _value.reFetch
: reFetch // ignore: cast_nullable_to_non_nullable
as void Function()?,
error: freezed == error
? _value.error
: error // ignore: cast_nullable_to_non_nullable
@ -91,7 +101,11 @@ abstract class _$$LoadableStateImplCopyWith<TState, $Res>
__$$LoadableStateImplCopyWithImpl<TState, $Res>;
@override
@useResult
$Res call({bool isLoading, TState? data, LoadingError? error});
$Res call(
{bool isLoading,
TState? data,
void Function()? reFetch,
LoadingError? error});
@override
$LoadingErrorCopyWith<$Res>? get error;
@ -111,6 +125,7 @@ class __$$LoadableStateImplCopyWithImpl<TState, $Res>
$Res call({
Object? isLoading = null,
Object? data = freezed,
Object? reFetch = freezed,
Object? error = freezed,
}) {
return _then(_$LoadableStateImpl<TState>(
@ -122,6 +137,10 @@ class __$$LoadableStateImplCopyWithImpl<TState, $Res>
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as TState?,
reFetch: freezed == reFetch
? _value.reFetch
: reFetch // ignore: cast_nullable_to_non_nullable
as void Function()?,
error: freezed == error
? _value.error
: error // ignore: cast_nullable_to_non_nullable
@ -134,7 +153,10 @@ class __$$LoadableStateImplCopyWithImpl<TState, $Res>
class _$LoadableStateImpl<TState> extends _LoadableState<TState> {
const _$LoadableStateImpl(
{this.isLoading = true, this.data = null, this.error = null})
{this.isLoading = true,
this.data = null,
this.reFetch = null,
this.error = null})
: super._();
@override
@ -145,11 +167,14 @@ class _$LoadableStateImpl<TState> extends _LoadableState<TState> {
final TState? data;
@override
@JsonKey()
final void Function()? reFetch;
@override
@JsonKey()
final LoadingError? error;
@override
String toString() {
return 'LoadableState<$TState>(isLoading: $isLoading, data: $data, error: $error)';
return 'LoadableState<$TState>(isLoading: $isLoading, data: $data, reFetch: $reFetch, error: $error)';
}
@override
@ -160,12 +185,13 @@ class _$LoadableStateImpl<TState> extends _LoadableState<TState> {
(identical(other.isLoading, isLoading) ||
other.isLoading == isLoading) &&
const DeepCollectionEquality().equals(other.data, data) &&
(identical(other.reFetch, reFetch) || other.reFetch == reFetch) &&
(identical(other.error, error) || other.error == error));
}
@override
int get hashCode => Object.hash(
runtimeType, isLoading, const DeepCollectionEquality().hash(data), error);
int get hashCode => Object.hash(runtimeType, isLoading,
const DeepCollectionEquality().hash(data), reFetch, error);
@JsonKey(ignore: true)
@override
@ -179,6 +205,7 @@ abstract class _LoadableState<TState> extends LoadableState<TState> {
const factory _LoadableState(
{final bool isLoading,
final TState? data,
final void Function()? reFetch,
final LoadingError? error}) = _$LoadableStateImpl<TState>;
const _LoadableState._() : super._();
@ -187,6 +214,8 @@ abstract class _LoadableState<TState> extends LoadableState<TState> {
@override
TState? get data;
@override
void Function()? get reFetch;
@override
LoadingError? get error;
@override
@JsonKey(ignore: true)