Game Prize and Logout
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/auth/auth.dart';
|
||||
|
||||
part 'logout_form_event.dart';
|
||||
part 'logout_form_state.dart';
|
||||
part 'logout_form_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class LogoutFormBloc extends Bloc<LogoutFormEvent, LogoutFormState> {
|
||||
final IAuthRepository _repository;
|
||||
|
||||
LogoutFormBloc(this._repository) : super(LogoutFormState.initial()) {
|
||||
on<LogoutFormEvent>(_onLogoutFormEvent);
|
||||
}
|
||||
|
||||
Future<void> _onLogoutFormEvent(
|
||||
LogoutFormEvent event,
|
||||
Emitter<LogoutFormState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
submitted: (e) async {
|
||||
emit(state.copyWith(isSubmitting: true, failureOrAuthOption: none()));
|
||||
final failureOrAuth = await _repository.logout();
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSubmitting: false,
|
||||
failureOrAuthOption: optionOf(failureOrAuth),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'logout_form_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LogoutFormEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $LogoutFormEventCopyWith<$Res> {
|
||||
factory $LogoutFormEventCopyWith(
|
||||
LogoutFormEvent value,
|
||||
$Res Function(LogoutFormEvent) then,
|
||||
) = _$LogoutFormEventCopyWithImpl<$Res, LogoutFormEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$LogoutFormEventCopyWithImpl<$Res, $Val extends LogoutFormEvent>
|
||||
implements $LogoutFormEventCopyWith<$Res> {
|
||||
_$LogoutFormEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of LogoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SubmittedImplCopyWith<$Res> {
|
||||
factory _$$SubmittedImplCopyWith(
|
||||
_$SubmittedImpl value,
|
||||
$Res Function(_$SubmittedImpl) then,
|
||||
) = __$$SubmittedImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SubmittedImplCopyWithImpl<$Res>
|
||||
extends _$LogoutFormEventCopyWithImpl<$Res, _$SubmittedImpl>
|
||||
implements _$$SubmittedImplCopyWith<$Res> {
|
||||
__$$SubmittedImplCopyWithImpl(
|
||||
_$SubmittedImpl _value,
|
||||
$Res Function(_$SubmittedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of LogoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SubmittedImpl implements _Submitted {
|
||||
const _$SubmittedImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LogoutFormEvent.submitted()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return submitted();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return submitted?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
return submitted();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return submitted(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return submitted?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
return submitted(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Submitted implements LogoutFormEvent {
|
||||
const factory _Submitted() = _$SubmittedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LogoutFormState {
|
||||
Option<Either<AuthFailure, Unit>> get failureOrAuthOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isSubmitting => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of LogoutFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$LogoutFormStateCopyWith<LogoutFormState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $LogoutFormStateCopyWith<$Res> {
|
||||
factory $LogoutFormStateCopyWith(
|
||||
LogoutFormState value,
|
||||
$Res Function(LogoutFormState) then,
|
||||
) = _$LogoutFormStateCopyWithImpl<$Res, LogoutFormState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
Option<Either<AuthFailure, Unit>> failureOrAuthOption,
|
||||
bool isSubmitting,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$LogoutFormStateCopyWithImpl<$Res, $Val extends LogoutFormState>
|
||||
implements $LogoutFormStateCopyWith<$Res> {
|
||||
_$LogoutFormStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of LogoutFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? failureOrAuthOption = null, Object? isSubmitting = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
failureOrAuthOption: null == failureOrAuthOption
|
||||
? _value.failureOrAuthOption
|
||||
: failureOrAuthOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<AuthFailure, Unit>>,
|
||||
isSubmitting: null == isSubmitting
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LogoutFormStateImplCopyWith<$Res>
|
||||
implements $LogoutFormStateCopyWith<$Res> {
|
||||
factory _$$LogoutFormStateImplCopyWith(
|
||||
_$LogoutFormStateImpl value,
|
||||
$Res Function(_$LogoutFormStateImpl) then,
|
||||
) = __$$LogoutFormStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
Option<Either<AuthFailure, Unit>> failureOrAuthOption,
|
||||
bool isSubmitting,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LogoutFormStateImplCopyWithImpl<$Res>
|
||||
extends _$LogoutFormStateCopyWithImpl<$Res, _$LogoutFormStateImpl>
|
||||
implements _$$LogoutFormStateImplCopyWith<$Res> {
|
||||
__$$LogoutFormStateImplCopyWithImpl(
|
||||
_$LogoutFormStateImpl _value,
|
||||
$Res Function(_$LogoutFormStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of LogoutFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? failureOrAuthOption = null, Object? isSubmitting = null}) {
|
||||
return _then(
|
||||
_$LogoutFormStateImpl(
|
||||
failureOrAuthOption: null == failureOrAuthOption
|
||||
? _value.failureOrAuthOption
|
||||
: failureOrAuthOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<AuthFailure, Unit>>,
|
||||
isSubmitting: null == isSubmitting
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LogoutFormStateImpl implements _LogoutFormState {
|
||||
const _$LogoutFormStateImpl({
|
||||
required this.failureOrAuthOption,
|
||||
this.isSubmitting = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final Option<Either<AuthFailure, Unit>> failureOrAuthOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isSubmitting;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LogoutFormState(failureOrAuthOption: $failureOrAuthOption, isSubmitting: $isSubmitting)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$LogoutFormStateImpl &&
|
||||
(identical(other.failureOrAuthOption, failureOrAuthOption) ||
|
||||
other.failureOrAuthOption == failureOrAuthOption) &&
|
||||
(identical(other.isSubmitting, isSubmitting) ||
|
||||
other.isSubmitting == isSubmitting));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, failureOrAuthOption, isSubmitting);
|
||||
|
||||
/// Create a copy of LogoutFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$LogoutFormStateImplCopyWith<_$LogoutFormStateImpl> get copyWith =>
|
||||
__$$LogoutFormStateImplCopyWithImpl<_$LogoutFormStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _LogoutFormState implements LogoutFormState {
|
||||
const factory _LogoutFormState({
|
||||
required final Option<Either<AuthFailure, Unit>> failureOrAuthOption,
|
||||
final bool isSubmitting,
|
||||
}) = _$LogoutFormStateImpl;
|
||||
|
||||
@override
|
||||
Option<Either<AuthFailure, Unit>> get failureOrAuthOption;
|
||||
@override
|
||||
bool get isSubmitting;
|
||||
|
||||
/// Create a copy of LogoutFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$LogoutFormStateImplCopyWith<_$LogoutFormStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'logout_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class LogoutFormEvent with _$LogoutFormEvent {
|
||||
const factory LogoutFormEvent.submitted() = _Submitted;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
part of 'logout_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class LogoutFormState with _$LogoutFormState {
|
||||
const factory LogoutFormState({
|
||||
required Option<Either<AuthFailure, Unit>> failureOrAuthOption,
|
||||
@Default(false) bool isSubmitting,
|
||||
}) = _LogoutFormState;
|
||||
|
||||
factory LogoutFormState.initial() =>
|
||||
LogoutFormState(failureOrAuthOption: none(), isSubmitting: false);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/game/game.dart';
|
||||
|
||||
part 'game_prize_loader_event.dart';
|
||||
part 'game_prize_loader_state.dart';
|
||||
part 'game_prize_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class GamePrizeLoaderBloc
|
||||
extends Bloc<GamePrizeLoaderEvent, GamePrizeLoaderState> {
|
||||
final IGameRepository _repository;
|
||||
GamePrizeLoaderBloc(this._repository)
|
||||
: super(GamePrizeLoaderState.initial()) {
|
||||
on<GamePrizeLoaderEvent>(_onGamePrizeLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onGamePrizeLoaderEvent(
|
||||
GamePrizeLoaderEvent event,
|
||||
Emitter<GamePrizeLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOptionGamePrize: none()));
|
||||
|
||||
final result = await _repository.gamePrizeByGameId(id: e.id);
|
||||
|
||||
var data = result.fold(
|
||||
(f) => state.copyWith(failureOptionGamePrize: optionOf(f)),
|
||||
(gamePrize) => state.copyWith(gamePrize: gamePrize),
|
||||
);
|
||||
|
||||
emit(data.copyWith(isFetching: false));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'game_prize_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GamePrizeLoaderEvent {
|
||||
String get id => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String id) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String id)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String id)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of GamePrizeLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$GamePrizeLoaderEventCopyWith<GamePrizeLoaderEvent> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $GamePrizeLoaderEventCopyWith<$Res> {
|
||||
factory $GamePrizeLoaderEventCopyWith(
|
||||
GamePrizeLoaderEvent value,
|
||||
$Res Function(GamePrizeLoaderEvent) then,
|
||||
) = _$GamePrizeLoaderEventCopyWithImpl<$Res, GamePrizeLoaderEvent>;
|
||||
@useResult
|
||||
$Res call({String id});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$GamePrizeLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends GamePrizeLoaderEvent
|
||||
>
|
||||
implements $GamePrizeLoaderEventCopyWith<$Res> {
|
||||
_$GamePrizeLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of GamePrizeLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? id = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res>
|
||||
implements $GamePrizeLoaderEventCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String id});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$GamePrizeLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of GamePrizeLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? id = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl(this.id);
|
||||
|
||||
@override
|
||||
final String id;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GamePrizeLoaderEvent.fetched(id: $id)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.id, id) || other.id == id));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id);
|
||||
|
||||
/// Create a copy of GamePrizeLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String id) fetched,
|
||||
}) {
|
||||
return fetched(id);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String id)? fetched,
|
||||
}) {
|
||||
return fetched?.call(id);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String id)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(id);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements GamePrizeLoaderEvent {
|
||||
const factory _Fetched(final String id) = _$FetchedImpl;
|
||||
|
||||
@override
|
||||
String get id;
|
||||
|
||||
/// Create a copy of GamePrizeLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GamePrizeLoaderState {
|
||||
List<GamePrize> get gamePrize => throw _privateConstructorUsedError;
|
||||
Option<GameFailure> get failureOptionGamePrize =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of GamePrizeLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$GamePrizeLoaderStateCopyWith<GamePrizeLoaderState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $GamePrizeLoaderStateCopyWith<$Res> {
|
||||
factory $GamePrizeLoaderStateCopyWith(
|
||||
GamePrizeLoaderState value,
|
||||
$Res Function(GamePrizeLoaderState) then,
|
||||
) = _$GamePrizeLoaderStateCopyWithImpl<$Res, GamePrizeLoaderState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<GamePrize> gamePrize,
|
||||
Option<GameFailure> failureOptionGamePrize,
|
||||
bool isFetching,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$GamePrizeLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends GamePrizeLoaderState
|
||||
>
|
||||
implements $GamePrizeLoaderStateCopyWith<$Res> {
|
||||
_$GamePrizeLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of GamePrizeLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? gamePrize = null,
|
||||
Object? failureOptionGamePrize = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
gamePrize: null == gamePrize
|
||||
? _value.gamePrize
|
||||
: gamePrize // ignore: cast_nullable_to_non_nullable
|
||||
as List<GamePrize>,
|
||||
failureOptionGamePrize: null == failureOptionGamePrize
|
||||
? _value.failureOptionGamePrize
|
||||
: failureOptionGamePrize // ignore: cast_nullable_to_non_nullable
|
||||
as Option<GameFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$GamePrizeLoaderStateImplCopyWith<$Res>
|
||||
implements $GamePrizeLoaderStateCopyWith<$Res> {
|
||||
factory _$$GamePrizeLoaderStateImplCopyWith(
|
||||
_$GamePrizeLoaderStateImpl value,
|
||||
$Res Function(_$GamePrizeLoaderStateImpl) then,
|
||||
) = __$$GamePrizeLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
List<GamePrize> gamePrize,
|
||||
Option<GameFailure> failureOptionGamePrize,
|
||||
bool isFetching,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$GamePrizeLoaderStateImplCopyWithImpl<$Res>
|
||||
extends _$GamePrizeLoaderStateCopyWithImpl<$Res, _$GamePrizeLoaderStateImpl>
|
||||
implements _$$GamePrizeLoaderStateImplCopyWith<$Res> {
|
||||
__$$GamePrizeLoaderStateImplCopyWithImpl(
|
||||
_$GamePrizeLoaderStateImpl _value,
|
||||
$Res Function(_$GamePrizeLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of GamePrizeLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? gamePrize = null,
|
||||
Object? failureOptionGamePrize = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$GamePrizeLoaderStateImpl(
|
||||
gamePrize: null == gamePrize
|
||||
? _value._gamePrize
|
||||
: gamePrize // ignore: cast_nullable_to_non_nullable
|
||||
as List<GamePrize>,
|
||||
failureOptionGamePrize: null == failureOptionGamePrize
|
||||
? _value.failureOptionGamePrize
|
||||
: failureOptionGamePrize // ignore: cast_nullable_to_non_nullable
|
||||
as Option<GameFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$GamePrizeLoaderStateImpl implements _GamePrizeLoaderState {
|
||||
const _$GamePrizeLoaderStateImpl({
|
||||
required final List<GamePrize> gamePrize,
|
||||
required this.failureOptionGamePrize,
|
||||
this.isFetching = false,
|
||||
}) : _gamePrize = gamePrize;
|
||||
|
||||
final List<GamePrize> _gamePrize;
|
||||
@override
|
||||
List<GamePrize> get gamePrize {
|
||||
if (_gamePrize is EqualUnmodifiableListView) return _gamePrize;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_gamePrize);
|
||||
}
|
||||
|
||||
@override
|
||||
final Option<GameFailure> failureOptionGamePrize;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GamePrizeLoaderState(gamePrize: $gamePrize, failureOptionGamePrize: $failureOptionGamePrize, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$GamePrizeLoaderStateImpl &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._gamePrize,
|
||||
_gamePrize,
|
||||
) &&
|
||||
(identical(other.failureOptionGamePrize, failureOptionGamePrize) ||
|
||||
other.failureOptionGamePrize == failureOptionGamePrize) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
const DeepCollectionEquality().hash(_gamePrize),
|
||||
failureOptionGamePrize,
|
||||
isFetching,
|
||||
);
|
||||
|
||||
/// Create a copy of GamePrizeLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$GamePrizeLoaderStateImplCopyWith<_$GamePrizeLoaderStateImpl>
|
||||
get copyWith =>
|
||||
__$$GamePrizeLoaderStateImplCopyWithImpl<_$GamePrizeLoaderStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _GamePrizeLoaderState implements GamePrizeLoaderState {
|
||||
const factory _GamePrizeLoaderState({
|
||||
required final List<GamePrize> gamePrize,
|
||||
required final Option<GameFailure> failureOptionGamePrize,
|
||||
final bool isFetching,
|
||||
}) = _$GamePrizeLoaderStateImpl;
|
||||
|
||||
@override
|
||||
List<GamePrize> get gamePrize;
|
||||
@override
|
||||
Option<GameFailure> get failureOptionGamePrize;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of GamePrizeLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$GamePrizeLoaderStateImplCopyWith<_$GamePrizeLoaderStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'game_prize_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class GamePrizeLoaderEvent with _$GamePrizeLoaderEvent {
|
||||
const factory GamePrizeLoaderEvent.fetched(String id) = _Fetched;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
part of 'game_prize_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class GamePrizeLoaderState with _$GamePrizeLoaderState {
|
||||
const factory GamePrizeLoaderState({
|
||||
required List<GamePrize> gamePrize,
|
||||
required Option<GameFailure> failureOptionGamePrize,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _GamePrizeLoaderState;
|
||||
|
||||
factory GamePrizeLoaderState.initial() =>
|
||||
GamePrizeLoaderState(gamePrize: [], failureOptionGamePrize: none());
|
||||
}
|
||||
Reference in New Issue
Block a user