loading state and error handling refactor
This commit is contained in:
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$LoadingError {
|
||||
|
||||
String get message; bool get allowRetry;
|
||||
String get message; String? get technicalDetails; bool get allowRetry;
|
||||
/// Create a copy of LoadingError
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $LoadingErrorCopyWith<LoadingError> get copyWith => _$LoadingErrorCopyWithImpl<L
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoadingError&&(identical(other.message, message) || other.message == message)&&(identical(other.allowRetry, allowRetry) || other.allowRetry == allowRetry));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoadingError&&(identical(other.message, message) || other.message == message)&&(identical(other.technicalDetails, technicalDetails) || other.technicalDetails == technicalDetails)&&(identical(other.allowRetry, allowRetry) || other.allowRetry == allowRetry));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,message,allowRetry);
|
||||
int get hashCode => Object.hash(runtimeType,message,technicalDetails,allowRetry);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LoadingError(message: $message, allowRetry: $allowRetry)';
|
||||
return 'LoadingError(message: $message, technicalDetails: $technicalDetails, allowRetry: $allowRetry)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $LoadingErrorCopyWith<$Res> {
|
||||
factory $LoadingErrorCopyWith(LoadingError value, $Res Function(LoadingError) _then) = _$LoadingErrorCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String message, bool allowRetry
|
||||
String message, String? technicalDetails, bool allowRetry
|
||||
});
|
||||
|
||||
|
||||
@@ -62,10 +62,11 @@ class _$LoadingErrorCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LoadingError
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? message = null,Object? allowRetry = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? message = null,Object? technicalDetails = freezed,Object? allowRetry = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
|
||||
as String,allowRetry: null == allowRetry ? _self.allowRetry : allowRetry // ignore: cast_nullable_to_non_nullable
|
||||
as String,technicalDetails: freezed == technicalDetails ? _self.technicalDetails : technicalDetails // ignore: cast_nullable_to_non_nullable
|
||||
as String?,allowRetry: null == allowRetry ? _self.allowRetry : allowRetry // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
@@ -151,10 +152,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String message, bool allowRetry)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String message, String? technicalDetails, bool allowRetry)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoadingError() when $default != null:
|
||||
return $default(_that.message,_that.allowRetry);case _:
|
||||
return $default(_that.message,_that.technicalDetails,_that.allowRetry);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -172,10 +173,10 @@ return $default(_that.message,_that.allowRetry);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String message, bool allowRetry) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String message, String? technicalDetails, bool allowRetry) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoadingError():
|
||||
return $default(_that.message,_that.allowRetry);case _:
|
||||
return $default(_that.message,_that.technicalDetails,_that.allowRetry);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -192,10 +193,10 @@ return $default(_that.message,_that.allowRetry);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String message, bool allowRetry)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String message, String? technicalDetails, bool allowRetry)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LoadingError() when $default != null:
|
||||
return $default(_that.message,_that.allowRetry);case _:
|
||||
return $default(_that.message,_that.technicalDetails,_that.allowRetry);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -207,10 +208,11 @@ return $default(_that.message,_that.allowRetry);case _:
|
||||
|
||||
|
||||
class _LoadingError implements LoadingError {
|
||||
const _LoadingError({required this.message, this.allowRetry = false});
|
||||
const _LoadingError({required this.message, this.technicalDetails, this.allowRetry = false});
|
||||
|
||||
|
||||
@override final String message;
|
||||
@override final String? technicalDetails;
|
||||
@override@JsonKey() final bool allowRetry;
|
||||
|
||||
/// Create a copy of LoadingError
|
||||
@@ -223,16 +225,16 @@ _$LoadingErrorCopyWith<_LoadingError> get copyWith => __$LoadingErrorCopyWithImp
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoadingError&&(identical(other.message, message) || other.message == message)&&(identical(other.allowRetry, allowRetry) || other.allowRetry == allowRetry));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoadingError&&(identical(other.message, message) || other.message == message)&&(identical(other.technicalDetails, technicalDetails) || other.technicalDetails == technicalDetails)&&(identical(other.allowRetry, allowRetry) || other.allowRetry == allowRetry));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,message,allowRetry);
|
||||
int get hashCode => Object.hash(runtimeType,message,technicalDetails,allowRetry);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LoadingError(message: $message, allowRetry: $allowRetry)';
|
||||
return 'LoadingError(message: $message, technicalDetails: $technicalDetails, allowRetry: $allowRetry)';
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +245,7 @@ abstract mixin class _$LoadingErrorCopyWith<$Res> implements $LoadingErrorCopyWi
|
||||
factory _$LoadingErrorCopyWith(_LoadingError value, $Res Function(_LoadingError) _then) = __$LoadingErrorCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String message, bool allowRetry
|
||||
String message, String? technicalDetails, bool allowRetry
|
||||
});
|
||||
|
||||
|
||||
@@ -260,10 +262,11 @@ class __$LoadingErrorCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LoadingError
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? message = null,Object? allowRetry = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? message = null,Object? technicalDetails = freezed,Object? allowRetry = null,}) {
|
||||
return _then(_LoadingError(
|
||||
message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
|
||||
as String,allowRetry: null == allowRetry ? _self.allowRetry : allowRetry // ignore: cast_nullable_to_non_nullable
|
||||
as String,technicalDetails: freezed == technicalDetails ? _self.technicalDetails : technicalDetails // ignore: cast_nullable_to_non_nullable
|
||||
as String?,allowRetry: null == allowRetry ? _self.allowRetry : allowRetry // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user