feat: change structure

This commit is contained in:
efrilm
2025-08-17 22:49:28 +07:00
parent 8eef620c16
commit b3c72cbbc0
11 changed files with 10 additions and 10 deletions
@@ -0,0 +1,44 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/analytic/analytic.dart';
import '../../../domain/analytic/repositories/i_analytic_repository.dart';
part 'profit_loss_loader_event.dart';
part 'profit_loss_loader_state.dart';
part 'profit_loss_loader_bloc.freezed.dart';
@injectable
class ProfitLossLoaderBloc
extends Bloc<ProfitLossLoaderEvent, ProfitLossLoaderState> {
final IAnalyticRepository _repository;
ProfitLossLoaderBloc(this._repository)
: super(ProfitLossLoaderState.initial()) {
on<ProfitLossLoaderEvent>(_onProfitLossLoaderEvent);
}
Future<void> _onProfitLossLoaderEvent(
ProfitLossLoaderEvent event,
Emitter<ProfitLossLoaderState> emit,
) {
return event.map(
fetched: (e) async {
emit(state.copyWith(isFetching: true, failureOptionProfitLoss: none()));
final result = await _repository.getProfitLoss(
dateFrom: DateTime.now().subtract(const Duration(days: 30)),
dateTo: DateTime.now(),
);
var data = result.fold(
(f) => state.copyWith(failureOptionProfitLoss: optionOf(f)),
(profitLoss) => state.copyWith(profitLoss: profitLoss),
);
emit(data.copyWith(isFetching: false));
},
);
}
}
@@ -0,0 +1,384 @@
// 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 'profit_loss_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 _$ProfitLossLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? 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;
}
/// @nodoc
abstract class $ProfitLossLoaderEventCopyWith<$Res> {
factory $ProfitLossLoaderEventCopyWith(
ProfitLossLoaderEvent value,
$Res Function(ProfitLossLoaderEvent) then,
) = _$ProfitLossLoaderEventCopyWithImpl<$Res, ProfitLossLoaderEvent>;
}
/// @nodoc
class _$ProfitLossLoaderEventCopyWithImpl<
$Res,
$Val extends ProfitLossLoaderEvent
>
implements $ProfitLossLoaderEventCopyWith<$Res> {
_$ProfitLossLoaderEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProfitLossLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchedImplCopyWith<$Res> {
factory _$$FetchedImplCopyWith(
_$FetchedImpl value,
$Res Function(_$FetchedImpl) then,
) = __$$FetchedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FetchedImplCopyWithImpl<$Res>
extends _$ProfitLossLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
implements _$$FetchedImplCopyWith<$Res> {
__$$FetchedImplCopyWithImpl(
_$FetchedImpl _value,
$Res Function(_$FetchedImpl) _then,
) : super(_value, _then);
/// Create a copy of ProfitLossLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchedImpl implements _Fetched {
const _$FetchedImpl();
@override
String toString() {
return 'ProfitLossLoaderEvent.fetched()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FetchedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({required TResult Function() fetched}) {
return fetched();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({TResult? Function()? fetched}) {
return fetched?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetched,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched();
}
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 ProfitLossLoaderEvent {
const factory _Fetched() = _$FetchedImpl;
}
/// @nodoc
mixin _$ProfitLossLoaderState {
ProfitLossAnalytic get profitLoss => throw _privateConstructorUsedError;
Option<AnalyticFailure> get failureOptionProfitLoss =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
/// Create a copy of ProfitLossLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ProfitLossLoaderStateCopyWith<ProfitLossLoaderState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProfitLossLoaderStateCopyWith<$Res> {
factory $ProfitLossLoaderStateCopyWith(
ProfitLossLoaderState value,
$Res Function(ProfitLossLoaderState) then,
) = _$ProfitLossLoaderStateCopyWithImpl<$Res, ProfitLossLoaderState>;
@useResult
$Res call({
ProfitLossAnalytic profitLoss,
Option<AnalyticFailure> failureOptionProfitLoss,
bool isFetching,
});
$ProfitLossAnalyticCopyWith<$Res> get profitLoss;
}
/// @nodoc
class _$ProfitLossLoaderStateCopyWithImpl<
$Res,
$Val extends ProfitLossLoaderState
>
implements $ProfitLossLoaderStateCopyWith<$Res> {
_$ProfitLossLoaderStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProfitLossLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? profitLoss = null,
Object? failureOptionProfitLoss = null,
Object? isFetching = null,
}) {
return _then(
_value.copyWith(
profitLoss: null == profitLoss
? _value.profitLoss
: profitLoss // ignore: cast_nullable_to_non_nullable
as ProfitLossAnalytic,
failureOptionProfitLoss: null == failureOptionProfitLoss
? _value.failureOptionProfitLoss
: failureOptionProfitLoss // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of ProfitLossLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ProfitLossAnalyticCopyWith<$Res> get profitLoss {
return $ProfitLossAnalyticCopyWith<$Res>(_value.profitLoss, (value) {
return _then(_value.copyWith(profitLoss: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$ProfitLossLoaderStateImplCopyWith<$Res>
implements $ProfitLossLoaderStateCopyWith<$Res> {
factory _$$ProfitLossLoaderStateImplCopyWith(
_$ProfitLossLoaderStateImpl value,
$Res Function(_$ProfitLossLoaderStateImpl) then,
) = __$$ProfitLossLoaderStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
ProfitLossAnalytic profitLoss,
Option<AnalyticFailure> failureOptionProfitLoss,
bool isFetching,
});
@override
$ProfitLossAnalyticCopyWith<$Res> get profitLoss;
}
/// @nodoc
class __$$ProfitLossLoaderStateImplCopyWithImpl<$Res>
extends
_$ProfitLossLoaderStateCopyWithImpl<$Res, _$ProfitLossLoaderStateImpl>
implements _$$ProfitLossLoaderStateImplCopyWith<$Res> {
__$$ProfitLossLoaderStateImplCopyWithImpl(
_$ProfitLossLoaderStateImpl _value,
$Res Function(_$ProfitLossLoaderStateImpl) _then,
) : super(_value, _then);
/// Create a copy of ProfitLossLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? profitLoss = null,
Object? failureOptionProfitLoss = null,
Object? isFetching = null,
}) {
return _then(
_$ProfitLossLoaderStateImpl(
profitLoss: null == profitLoss
? _value.profitLoss
: profitLoss // ignore: cast_nullable_to_non_nullable
as ProfitLossAnalytic,
failureOptionProfitLoss: null == failureOptionProfitLoss
? _value.failureOptionProfitLoss
: failureOptionProfitLoss // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$ProfitLossLoaderStateImpl implements _ProfitLossLoaderState {
const _$ProfitLossLoaderStateImpl({
required this.profitLoss,
required this.failureOptionProfitLoss,
this.isFetching = false,
});
@override
final ProfitLossAnalytic profitLoss;
@override
final Option<AnalyticFailure> failureOptionProfitLoss;
@override
@JsonKey()
final bool isFetching;
@override
String toString() {
return 'ProfitLossLoaderState(profitLoss: $profitLoss, failureOptionProfitLoss: $failureOptionProfitLoss, isFetching: $isFetching)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProfitLossLoaderStateImpl &&
(identical(other.profitLoss, profitLoss) ||
other.profitLoss == profitLoss) &&
(identical(
other.failureOptionProfitLoss,
failureOptionProfitLoss,
) ||
other.failureOptionProfitLoss == failureOptionProfitLoss) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching));
}
@override
int get hashCode =>
Object.hash(runtimeType, profitLoss, failureOptionProfitLoss, isFetching);
/// Create a copy of ProfitLossLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProfitLossLoaderStateImplCopyWith<_$ProfitLossLoaderStateImpl>
get copyWith =>
__$$ProfitLossLoaderStateImplCopyWithImpl<_$ProfitLossLoaderStateImpl>(
this,
_$identity,
);
}
abstract class _ProfitLossLoaderState implements ProfitLossLoaderState {
const factory _ProfitLossLoaderState({
required final ProfitLossAnalytic profitLoss,
required final Option<AnalyticFailure> failureOptionProfitLoss,
final bool isFetching,
}) = _$ProfitLossLoaderStateImpl;
@override
ProfitLossAnalytic get profitLoss;
@override
Option<AnalyticFailure> get failureOptionProfitLoss;
@override
bool get isFetching;
/// Create a copy of ProfitLossLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProfitLossLoaderStateImplCopyWith<_$ProfitLossLoaderStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,6 @@
part of 'profit_loss_loader_bloc.dart';
@freezed
class ProfitLossLoaderEvent with _$ProfitLossLoaderEvent {
const factory ProfitLossLoaderEvent.fetched() = _Fetched;
}
@@ -0,0 +1,15 @@
part of 'profit_loss_loader_bloc.dart';
@freezed
class ProfitLossLoaderState with _$ProfitLossLoaderState {
const factory ProfitLossLoaderState({
required ProfitLossAnalytic profitLoss,
required Option<AnalyticFailure> failureOptionProfitLoss,
@Default(false) bool isFetching,
}) = _ProfitLossLoaderState;
factory ProfitLossLoaderState.initial() => ProfitLossLoaderState(
profitLoss: ProfitLossAnalytic.empty(),
failureOptionProfitLoss: none(),
);
}
@@ -0,0 +1,39 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/analytic/analytic.dart';
import '../../../domain/analytic/repositories/i_analytic_repository.dart';
part 'sales_loader_event.dart';
part 'sales_loader_state.dart';
part 'sales_loader_bloc.freezed.dart';
@injectable
class SalesLoaderBloc extends Bloc<SalesLoaderEvent, SalesLoaderState> {
final IAnalyticRepository _analyticRepository;
SalesLoaderBloc(this._analyticRepository)
: super(SalesLoaderState.initial()) {
on<SalesLoaderEvent>(_onSalesLoaderEvent);
}
Future<void> _onSalesLoaderEvent(
SalesLoaderEvent event,
Emitter<SalesLoaderState> emit,
) async {
emit(state.copyWith(isFetching: true, failureOptionSales: none()));
final result = await _analyticRepository.getSales(
dateFrom: DateTime.now().subtract(const Duration(days: 30)),
dateTo: DateTime.now(),
);
var data = result.fold(
(f) => state.copyWith(failureOptionSales: optionOf(f)),
(sales) => state.copyWith(sales: sales),
);
emit(data.copyWith(isFetching: false));
}
}
@@ -0,0 +1,376 @@
// 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 'sales_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 _$SalesLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fectched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fectched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fectched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fectched value) fectched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fectched value)? fectched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fectched value)? fectched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SalesLoaderEventCopyWith<$Res> {
factory $SalesLoaderEventCopyWith(
SalesLoaderEvent value,
$Res Function(SalesLoaderEvent) then,
) = _$SalesLoaderEventCopyWithImpl<$Res, SalesLoaderEvent>;
}
/// @nodoc
class _$SalesLoaderEventCopyWithImpl<$Res, $Val extends SalesLoaderEvent>
implements $SalesLoaderEventCopyWith<$Res> {
_$SalesLoaderEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SalesLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FectchedImplCopyWith<$Res> {
factory _$$FectchedImplCopyWith(
_$FectchedImpl value,
$Res Function(_$FectchedImpl) then,
) = __$$FectchedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FectchedImplCopyWithImpl<$Res>
extends _$SalesLoaderEventCopyWithImpl<$Res, _$FectchedImpl>
implements _$$FectchedImplCopyWith<$Res> {
__$$FectchedImplCopyWithImpl(
_$FectchedImpl _value,
$Res Function(_$FectchedImpl) _then,
) : super(_value, _then);
/// Create a copy of SalesLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FectchedImpl implements _Fectched {
const _$FectchedImpl();
@override
String toString() {
return 'SalesLoaderEvent.fectched()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FectchedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fectched,
}) {
return fectched();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fectched,
}) {
return fectched?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fectched,
required TResult orElse(),
}) {
if (fectched != null) {
return fectched();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fectched value) fectched,
}) {
return fectched(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fectched value)? fectched,
}) {
return fectched?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fectched value)? fectched,
required TResult orElse(),
}) {
if (fectched != null) {
return fectched(this);
}
return orElse();
}
}
abstract class _Fectched implements SalesLoaderEvent {
const factory _Fectched() = _$FectchedImpl;
}
/// @nodoc
mixin _$SalesLoaderState {
SalesAnalytic get sales => throw _privateConstructorUsedError;
Option<AnalyticFailure> get failureOptionSales =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
/// Create a copy of SalesLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$SalesLoaderStateCopyWith<SalesLoaderState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SalesLoaderStateCopyWith<$Res> {
factory $SalesLoaderStateCopyWith(
SalesLoaderState value,
$Res Function(SalesLoaderState) then,
) = _$SalesLoaderStateCopyWithImpl<$Res, SalesLoaderState>;
@useResult
$Res call({
SalesAnalytic sales,
Option<AnalyticFailure> failureOptionSales,
bool isFetching,
});
$SalesAnalyticCopyWith<$Res> get sales;
}
/// @nodoc
class _$SalesLoaderStateCopyWithImpl<$Res, $Val extends SalesLoaderState>
implements $SalesLoaderStateCopyWith<$Res> {
_$SalesLoaderStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SalesLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? sales = null,
Object? failureOptionSales = null,
Object? isFetching = null,
}) {
return _then(
_value.copyWith(
sales: null == sales
? _value.sales
: sales // ignore: cast_nullable_to_non_nullable
as SalesAnalytic,
failureOptionSales: null == failureOptionSales
? _value.failureOptionSales
: failureOptionSales // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of SalesLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$SalesAnalyticCopyWith<$Res> get sales {
return $SalesAnalyticCopyWith<$Res>(_value.sales, (value) {
return _then(_value.copyWith(sales: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$SalesLoaderStateImplCopyWith<$Res>
implements $SalesLoaderStateCopyWith<$Res> {
factory _$$SalesLoaderStateImplCopyWith(
_$SalesLoaderStateImpl value,
$Res Function(_$SalesLoaderStateImpl) then,
) = __$$SalesLoaderStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
SalesAnalytic sales,
Option<AnalyticFailure> failureOptionSales,
bool isFetching,
});
@override
$SalesAnalyticCopyWith<$Res> get sales;
}
/// @nodoc
class __$$SalesLoaderStateImplCopyWithImpl<$Res>
extends _$SalesLoaderStateCopyWithImpl<$Res, _$SalesLoaderStateImpl>
implements _$$SalesLoaderStateImplCopyWith<$Res> {
__$$SalesLoaderStateImplCopyWithImpl(
_$SalesLoaderStateImpl _value,
$Res Function(_$SalesLoaderStateImpl) _then,
) : super(_value, _then);
/// Create a copy of SalesLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? sales = null,
Object? failureOptionSales = null,
Object? isFetching = null,
}) {
return _then(
_$SalesLoaderStateImpl(
sales: null == sales
? _value.sales
: sales // ignore: cast_nullable_to_non_nullable
as SalesAnalytic,
failureOptionSales: null == failureOptionSales
? _value.failureOptionSales
: failureOptionSales // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$SalesLoaderStateImpl implements _SalesLoaderState {
const _$SalesLoaderStateImpl({
required this.sales,
required this.failureOptionSales,
this.isFetching = false,
});
@override
final SalesAnalytic sales;
@override
final Option<AnalyticFailure> failureOptionSales;
@override
@JsonKey()
final bool isFetching;
@override
String toString() {
return 'SalesLoaderState(sales: $sales, failureOptionSales: $failureOptionSales, isFetching: $isFetching)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SalesLoaderStateImpl &&
(identical(other.sales, sales) || other.sales == sales) &&
(identical(other.failureOptionSales, failureOptionSales) ||
other.failureOptionSales == failureOptionSales) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching));
}
@override
int get hashCode =>
Object.hash(runtimeType, sales, failureOptionSales, isFetching);
/// Create a copy of SalesLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SalesLoaderStateImplCopyWith<_$SalesLoaderStateImpl> get copyWith =>
__$$SalesLoaderStateImplCopyWithImpl<_$SalesLoaderStateImpl>(
this,
_$identity,
);
}
abstract class _SalesLoaderState implements SalesLoaderState {
const factory _SalesLoaderState({
required final SalesAnalytic sales,
required final Option<AnalyticFailure> failureOptionSales,
final bool isFetching,
}) = _$SalesLoaderStateImpl;
@override
SalesAnalytic get sales;
@override
Option<AnalyticFailure> get failureOptionSales;
@override
bool get isFetching;
/// Create a copy of SalesLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SalesLoaderStateImplCopyWith<_$SalesLoaderStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -0,0 +1,6 @@
part of 'sales_loader_bloc.dart';
@freezed
class SalesLoaderEvent with _$SalesLoaderEvent {
const factory SalesLoaderEvent.fectched() = _Fectched;
}
@@ -0,0 +1,15 @@
part of 'sales_loader_bloc.dart';
@freezed
class SalesLoaderState with _$SalesLoaderState {
const factory SalesLoaderState({
required SalesAnalytic sales,
required Option<AnalyticFailure> failureOptionSales,
@Default(false) bool isFetching,
}) = _SalesLoaderState;
factory SalesLoaderState.initial() => SalesLoaderState(
sales: SalesAnalytic.empty(),
failureOptionSales: none(),
);
}