forked from eatvio/eatvio_app
my plans and my diets
This commit is contained in:
207
lib/features/my_plans/presentation/cubit/my_plans_cubit.dart
Normal file
207
lib/features/my_plans/presentation/cubit/my_plans_cubit.dart
Normal file
@@ -0,0 +1,207 @@
|
||||
import 'package:easy_debounce/easy_debounce.dart';
|
||||
import 'package:eatvio_app/core/const.dart';
|
||||
import 'package:eatvio_app/features/my_plans/presentation/cubit/my_plans_state.dart';
|
||||
import 'package:eatvio_app/features/my_plans/repositories/my_diets_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class MyPlansCubit extends Cubit<MyPlansState> {
|
||||
final MyPlansRepository myPlansRepository;
|
||||
|
||||
int currentDraftPage = 1;
|
||||
int currentActivePage = 1;
|
||||
late int lastDraftPage;
|
||||
late int lastPersonalPage;
|
||||
late int lastActivePage;
|
||||
bool isLoadingDraft = false;
|
||||
bool isLoadingActive = false;
|
||||
String? _activeQuery;
|
||||
String? _draftQuery;
|
||||
|
||||
static const List<int?> _durationValues = [null, ...durationValues];
|
||||
static const List<String?> _types = [null, ...planTypeValues];
|
||||
|
||||
MyPlansCubit({required this.myPlansRepository}) : super(MyPlansState());
|
||||
|
||||
void changePriceFilter(int minPrice, int maxPrice, {bool disableDebounce = false}) {
|
||||
if (state.selectedStateIndex == 0) {
|
||||
emit(state.copyWith(activeFilterState: state.activeFilterState.copyWith(priceFilter: (minPrice, maxPrice)), error: null));
|
||||
EasyDebounce.debounce(
|
||||
'loadPlans',
|
||||
Duration(seconds: disableDebounce ? 0 : 1),
|
||||
() => loadPlans(
|
||||
query: _activeQuery,
|
||||
),
|
||||
);
|
||||
} else if (state.selectedStateIndex == 1) {
|
||||
emit(state.copyWith(draftFilterState: state.draftFilterState.copyWith(priceFilter: (minPrice, maxPrice)), error: null));
|
||||
EasyDebounce.debounce(
|
||||
'loadPlans',
|
||||
Duration(seconds: disableDebounce ? 0 : 1),
|
||||
() => loadPlans(
|
||||
query: _draftQuery,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void changeTypeFilter(int index) {
|
||||
if (state.selectedStateIndex == 0) {
|
||||
emit(state.copyWith(activeFilterState: state.activeFilterState.copyWith(typeIndex: index), error: null));
|
||||
EasyDebounce.debounce(
|
||||
'loadPlans',
|
||||
Duration(seconds: 1),
|
||||
() => loadPlans(
|
||||
query: _activeQuery,
|
||||
),
|
||||
);
|
||||
} else if (state.selectedStateIndex == 1) {
|
||||
emit(state.copyWith(draftFilterState: state.draftFilterState.copyWith(typeIndex: index), error: null));
|
||||
EasyDebounce.debounce(
|
||||
'loadPlans',
|
||||
Duration(seconds: 1),
|
||||
() => loadPlans(
|
||||
query: _draftQuery,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void changeDurationFilter(int index) {
|
||||
if (state.selectedStateIndex == 0) {
|
||||
emit(state.copyWith(activeFilterState: state.activeFilterState.copyWith(durationIndex: index), error: null));
|
||||
EasyDebounce.debounce(
|
||||
'loadPlans',
|
||||
Duration(seconds: 1),
|
||||
() => loadPlans(
|
||||
query: _activeQuery,
|
||||
),
|
||||
);
|
||||
} else if (state.selectedStateIndex == 1) {
|
||||
emit(state.copyWith(draftFilterState: state.draftFilterState.copyWith(durationIndex: index), error: null));
|
||||
EasyDebounce.debounce(
|
||||
'loadPlans',
|
||||
Duration(seconds: 1),
|
||||
() => loadPlans(
|
||||
query: _draftQuery,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void changeSelectedStateIndex(int index) {
|
||||
emit(state.copyWith(selectedStateIndex: index));
|
||||
}
|
||||
|
||||
Future<void> loadPlans({
|
||||
String? query,
|
||||
}) async {
|
||||
switch (state.selectedStateIndex) {
|
||||
case 0:
|
||||
await _loadActivePlans(query: query);
|
||||
break;
|
||||
case 1:
|
||||
await _loadDraftPlans(query: query);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadAllPlans() async {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
await _loadActivePlans();
|
||||
await _loadDraftPlans();
|
||||
emit(state.copyWith(isLoading: false));
|
||||
}
|
||||
|
||||
Future<void> _loadActivePlans({String? query}) async {
|
||||
try {
|
||||
_activeQuery = query;
|
||||
final type = _types[state.activeFilterState.typeIndex];
|
||||
final duration = _durationValues[state.activeFilterState.durationIndex];
|
||||
final minPrice = state.activeFilterState.priceFilter.$1;
|
||||
final maxPrice = state.activeFilterState.priceFilter.$2;
|
||||
final plansPagination = await myPlansRepository.getPlans(
|
||||
query: query,
|
||||
duration: duration,
|
||||
maxPrice: maxPrice,
|
||||
minPrice: minPrice,
|
||||
types: type,
|
||||
);
|
||||
lastActivePage = plansPagination.meta.lastPage;
|
||||
final minPlanPrice = plansPagination.meta.totalMinPrice ?? 0;
|
||||
final maxPlanPrice = plansPagination.meta.totalMaxPrice ?? 0;
|
||||
if (state.activeFilterState.priceFilter.$1 == null || state.activeFilterState.priceFilter.$2 == null) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
activeFilterState: state.activeFilterState.copyWith(priceFilter: (minPlanPrice, maxPlanPrice)),
|
||||
),
|
||||
);
|
||||
}
|
||||
emit(
|
||||
state.copyWith(
|
||||
activePlans: plansPagination.data,
|
||||
isLoading: isLoadingActive,
|
||||
error: null,
|
||||
minActivePlanPrice: minPlanPrice,
|
||||
maxActivePlanPrice: maxPlanPrice,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(error: e.toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadDraftPlans({String? query}) async {
|
||||
try {
|
||||
_draftQuery = query;
|
||||
final type = _types[state.draftFilterState.typeIndex];
|
||||
final duration = _durationValues[state.draftFilterState.durationIndex];
|
||||
final minPrice = state.draftFilterState.priceFilter.$1;
|
||||
final maxPrice = state.draftFilterState.priceFilter.$2;
|
||||
final plansPagination = await myPlansRepository.getPlans(
|
||||
query: query,
|
||||
duration: duration,
|
||||
maxPrice: maxPrice,
|
||||
minPrice: minPrice,
|
||||
types: type,
|
||||
);
|
||||
lastDraftPage = plansPagination.meta.lastPage;
|
||||
final minPlanPrice = plansPagination.meta.totalMinPrice ?? 0;
|
||||
final maxPlanPrice = plansPagination.meta.totalMaxPrice ?? 0;
|
||||
if (state.draftFilterState.priceFilter.$1 == null || state.draftFilterState.priceFilter.$2 == null) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
draftFilterState: state.draftFilterState.copyWith(priceFilter: (minPlanPrice, maxPlanPrice)),
|
||||
),
|
||||
);
|
||||
}
|
||||
emit(
|
||||
state.copyWith(
|
||||
draftPlans: plansPagination.data,
|
||||
isLoading: isLoadingDraft,
|
||||
error: null,
|
||||
minDraftPlanPrice: minPlanPrice,
|
||||
maxDraftPlanPrice: maxPlanPrice,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(error: e.toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> deletePlan(String slug) async {
|
||||
try {
|
||||
await myPlansRepository.deletePlan(slug);
|
||||
await loadAllPlans();
|
||||
return true;
|
||||
} catch (e) {
|
||||
emit(
|
||||
state.copyWith(error: e.toString()),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
lib/features/my_plans/presentation/cubit/my_plans_state.dart
Normal file
36
lib/features/my_plans/presentation/cubit/my_plans_state.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/bloc/plans_cubit/plans_state.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'my_plans_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class MyPlansState with _$MyPlansState {
|
||||
factory MyPlansState({
|
||||
@Default([]) List<PlanModel> activePlans,
|
||||
@Default([]) List<PlanModel> draftPlans,
|
||||
@Default(false) bool isLoading,
|
||||
@Default(null) String? error,
|
||||
@Default(0) int selectedStateIndex,
|
||||
@Default(0) int minActivePlanPrice,
|
||||
@Default(0) int maxActivePlanPrice,
|
||||
@Default(0) int minDraftPlanPrice,
|
||||
@Default(0) int maxDraftPlanPrice,
|
||||
@Default(
|
||||
const PlansFilterState(
|
||||
priceFilter: (null, null),
|
||||
durationIndex: 0,
|
||||
typeIndex: 0,
|
||||
),
|
||||
)
|
||||
PlansFilterState activeFilterState,
|
||||
@Default(
|
||||
const PlansFilterState(
|
||||
priceFilter: (null, null),
|
||||
durationIndex: 0,
|
||||
typeIndex: 0,
|
||||
),
|
||||
)
|
||||
PlansFilterState draftFilterState,
|
||||
}) = _MyPlansState;
|
||||
}
|
||||
@@ -0,0 +1,424 @@
|
||||
// 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 'my_plans_state.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 _$MyPlansState {
|
||||
List<PlanModel> get activePlans => throw _privateConstructorUsedError;
|
||||
List<PlanModel> get draftPlans => throw _privateConstructorUsedError;
|
||||
bool get isLoading => throw _privateConstructorUsedError;
|
||||
String? get error => throw _privateConstructorUsedError;
|
||||
int get selectedStateIndex => throw _privateConstructorUsedError;
|
||||
int get minActivePlanPrice => throw _privateConstructorUsedError;
|
||||
int get maxActivePlanPrice => throw _privateConstructorUsedError;
|
||||
int get minDraftPlanPrice => throw _privateConstructorUsedError;
|
||||
int get maxDraftPlanPrice => throw _privateConstructorUsedError;
|
||||
PlansFilterState get activeFilterState => throw _privateConstructorUsedError;
|
||||
PlansFilterState get draftFilterState => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of MyPlansState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$MyPlansStateCopyWith<MyPlansState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $MyPlansStateCopyWith<$Res> {
|
||||
factory $MyPlansStateCopyWith(
|
||||
MyPlansState value, $Res Function(MyPlansState) then) =
|
||||
_$MyPlansStateCopyWithImpl<$Res, MyPlansState>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{List<PlanModel> activePlans,
|
||||
List<PlanModel> draftPlans,
|
||||
bool isLoading,
|
||||
String? error,
|
||||
int selectedStateIndex,
|
||||
int minActivePlanPrice,
|
||||
int maxActivePlanPrice,
|
||||
int minDraftPlanPrice,
|
||||
int maxDraftPlanPrice,
|
||||
PlansFilterState activeFilterState,
|
||||
PlansFilterState draftFilterState});
|
||||
|
||||
$PlansFilterStateCopyWith<$Res> get activeFilterState;
|
||||
$PlansFilterStateCopyWith<$Res> get draftFilterState;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$MyPlansStateCopyWithImpl<$Res, $Val extends MyPlansState>
|
||||
implements $MyPlansStateCopyWith<$Res> {
|
||||
_$MyPlansStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of MyPlansState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? activePlans = null,
|
||||
Object? draftPlans = null,
|
||||
Object? isLoading = null,
|
||||
Object? error = freezed,
|
||||
Object? selectedStateIndex = null,
|
||||
Object? minActivePlanPrice = null,
|
||||
Object? maxActivePlanPrice = null,
|
||||
Object? minDraftPlanPrice = null,
|
||||
Object? maxDraftPlanPrice = null,
|
||||
Object? activeFilterState = null,
|
||||
Object? draftFilterState = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
activePlans: null == activePlans
|
||||
? _value.activePlans
|
||||
: activePlans // ignore: cast_nullable_to_non_nullable
|
||||
as List<PlanModel>,
|
||||
draftPlans: null == draftPlans
|
||||
? _value.draftPlans
|
||||
: draftPlans // ignore: cast_nullable_to_non_nullable
|
||||
as List<PlanModel>,
|
||||
isLoading: null == isLoading
|
||||
? _value.isLoading
|
||||
: isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
error: freezed == error
|
||||
? _value.error
|
||||
: error // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
selectedStateIndex: null == selectedStateIndex
|
||||
? _value.selectedStateIndex
|
||||
: selectedStateIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
minActivePlanPrice: null == minActivePlanPrice
|
||||
? _value.minActivePlanPrice
|
||||
: minActivePlanPrice // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
maxActivePlanPrice: null == maxActivePlanPrice
|
||||
? _value.maxActivePlanPrice
|
||||
: maxActivePlanPrice // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
minDraftPlanPrice: null == minDraftPlanPrice
|
||||
? _value.minDraftPlanPrice
|
||||
: minDraftPlanPrice // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
maxDraftPlanPrice: null == maxDraftPlanPrice
|
||||
? _value.maxDraftPlanPrice
|
||||
: maxDraftPlanPrice // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
activeFilterState: null == activeFilterState
|
||||
? _value.activeFilterState
|
||||
: activeFilterState // ignore: cast_nullable_to_non_nullable
|
||||
as PlansFilterState,
|
||||
draftFilterState: null == draftFilterState
|
||||
? _value.draftFilterState
|
||||
: draftFilterState // ignore: cast_nullable_to_non_nullable
|
||||
as PlansFilterState,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
/// Create a copy of MyPlansState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$PlansFilterStateCopyWith<$Res> get activeFilterState {
|
||||
return $PlansFilterStateCopyWith<$Res>(_value.activeFilterState, (value) {
|
||||
return _then(_value.copyWith(activeFilterState: value) as $Val);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of MyPlansState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$PlansFilterStateCopyWith<$Res> get draftFilterState {
|
||||
return $PlansFilterStateCopyWith<$Res>(_value.draftFilterState, (value) {
|
||||
return _then(_value.copyWith(draftFilterState: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$MyPlansStateImplCopyWith<$Res>
|
||||
implements $MyPlansStateCopyWith<$Res> {
|
||||
factory _$$MyPlansStateImplCopyWith(
|
||||
_$MyPlansStateImpl value, $Res Function(_$MyPlansStateImpl) then) =
|
||||
__$$MyPlansStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{List<PlanModel> activePlans,
|
||||
List<PlanModel> draftPlans,
|
||||
bool isLoading,
|
||||
String? error,
|
||||
int selectedStateIndex,
|
||||
int minActivePlanPrice,
|
||||
int maxActivePlanPrice,
|
||||
int minDraftPlanPrice,
|
||||
int maxDraftPlanPrice,
|
||||
PlansFilterState activeFilterState,
|
||||
PlansFilterState draftFilterState});
|
||||
|
||||
@override
|
||||
$PlansFilterStateCopyWith<$Res> get activeFilterState;
|
||||
@override
|
||||
$PlansFilterStateCopyWith<$Res> get draftFilterState;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$MyPlansStateImplCopyWithImpl<$Res>
|
||||
extends _$MyPlansStateCopyWithImpl<$Res, _$MyPlansStateImpl>
|
||||
implements _$$MyPlansStateImplCopyWith<$Res> {
|
||||
__$$MyPlansStateImplCopyWithImpl(
|
||||
_$MyPlansStateImpl _value, $Res Function(_$MyPlansStateImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of MyPlansState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? activePlans = null,
|
||||
Object? draftPlans = null,
|
||||
Object? isLoading = null,
|
||||
Object? error = freezed,
|
||||
Object? selectedStateIndex = null,
|
||||
Object? minActivePlanPrice = null,
|
||||
Object? maxActivePlanPrice = null,
|
||||
Object? minDraftPlanPrice = null,
|
||||
Object? maxDraftPlanPrice = null,
|
||||
Object? activeFilterState = null,
|
||||
Object? draftFilterState = null,
|
||||
}) {
|
||||
return _then(_$MyPlansStateImpl(
|
||||
activePlans: null == activePlans
|
||||
? _value._activePlans
|
||||
: activePlans // ignore: cast_nullable_to_non_nullable
|
||||
as List<PlanModel>,
|
||||
draftPlans: null == draftPlans
|
||||
? _value._draftPlans
|
||||
: draftPlans // ignore: cast_nullable_to_non_nullable
|
||||
as List<PlanModel>,
|
||||
isLoading: null == isLoading
|
||||
? _value.isLoading
|
||||
: isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
error: freezed == error
|
||||
? _value.error
|
||||
: error // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
selectedStateIndex: null == selectedStateIndex
|
||||
? _value.selectedStateIndex
|
||||
: selectedStateIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
minActivePlanPrice: null == minActivePlanPrice
|
||||
? _value.minActivePlanPrice
|
||||
: minActivePlanPrice // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
maxActivePlanPrice: null == maxActivePlanPrice
|
||||
? _value.maxActivePlanPrice
|
||||
: maxActivePlanPrice // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
minDraftPlanPrice: null == minDraftPlanPrice
|
||||
? _value.minDraftPlanPrice
|
||||
: minDraftPlanPrice // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
maxDraftPlanPrice: null == maxDraftPlanPrice
|
||||
? _value.maxDraftPlanPrice
|
||||
: maxDraftPlanPrice // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
activeFilterState: null == activeFilterState
|
||||
? _value.activeFilterState
|
||||
: activeFilterState // ignore: cast_nullable_to_non_nullable
|
||||
as PlansFilterState,
|
||||
draftFilterState: null == draftFilterState
|
||||
? _value.draftFilterState
|
||||
: draftFilterState // ignore: cast_nullable_to_non_nullable
|
||||
as PlansFilterState,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$MyPlansStateImpl implements _MyPlansState {
|
||||
_$MyPlansStateImpl(
|
||||
{final List<PlanModel> activePlans = const [],
|
||||
final List<PlanModel> draftPlans = const [],
|
||||
this.isLoading = false,
|
||||
this.error = null,
|
||||
this.selectedStateIndex = 0,
|
||||
this.minActivePlanPrice = 0,
|
||||
this.maxActivePlanPrice = 0,
|
||||
this.minDraftPlanPrice = 0,
|
||||
this.maxDraftPlanPrice = 0,
|
||||
this.activeFilterState = const PlansFilterState(
|
||||
priceFilter: (null, null), durationIndex: 0, typeIndex: 0),
|
||||
this.draftFilterState = const PlansFilterState(
|
||||
priceFilter: (null, null), durationIndex: 0, typeIndex: 0)})
|
||||
: _activePlans = activePlans,
|
||||
_draftPlans = draftPlans;
|
||||
|
||||
final List<PlanModel> _activePlans;
|
||||
@override
|
||||
@JsonKey()
|
||||
List<PlanModel> get activePlans {
|
||||
if (_activePlans is EqualUnmodifiableListView) return _activePlans;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_activePlans);
|
||||
}
|
||||
|
||||
final List<PlanModel> _draftPlans;
|
||||
@override
|
||||
@JsonKey()
|
||||
List<PlanModel> get draftPlans {
|
||||
if (_draftPlans is EqualUnmodifiableListView) return _draftPlans;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_draftPlans);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isLoading;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String? error;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int selectedStateIndex;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int minActivePlanPrice;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int maxActivePlanPrice;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int minDraftPlanPrice;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int maxDraftPlanPrice;
|
||||
@override
|
||||
@JsonKey()
|
||||
final PlansFilterState activeFilterState;
|
||||
@override
|
||||
@JsonKey()
|
||||
final PlansFilterState draftFilterState;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MyPlansState(activePlans: $activePlans, draftPlans: $draftPlans, isLoading: $isLoading, error: $error, selectedStateIndex: $selectedStateIndex, minActivePlanPrice: $minActivePlanPrice, maxActivePlanPrice: $maxActivePlanPrice, minDraftPlanPrice: $minDraftPlanPrice, maxDraftPlanPrice: $maxDraftPlanPrice, activeFilterState: $activeFilterState, draftFilterState: $draftFilterState)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$MyPlansStateImpl &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._activePlans, _activePlans) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._draftPlans, _draftPlans) &&
|
||||
(identical(other.isLoading, isLoading) ||
|
||||
other.isLoading == isLoading) &&
|
||||
(identical(other.error, error) || other.error == error) &&
|
||||
(identical(other.selectedStateIndex, selectedStateIndex) ||
|
||||
other.selectedStateIndex == selectedStateIndex) &&
|
||||
(identical(other.minActivePlanPrice, minActivePlanPrice) ||
|
||||
other.minActivePlanPrice == minActivePlanPrice) &&
|
||||
(identical(other.maxActivePlanPrice, maxActivePlanPrice) ||
|
||||
other.maxActivePlanPrice == maxActivePlanPrice) &&
|
||||
(identical(other.minDraftPlanPrice, minDraftPlanPrice) ||
|
||||
other.minDraftPlanPrice == minDraftPlanPrice) &&
|
||||
(identical(other.maxDraftPlanPrice, maxDraftPlanPrice) ||
|
||||
other.maxDraftPlanPrice == maxDraftPlanPrice) &&
|
||||
(identical(other.activeFilterState, activeFilterState) ||
|
||||
other.activeFilterState == activeFilterState) &&
|
||||
(identical(other.draftFilterState, draftFilterState) ||
|
||||
other.draftFilterState == draftFilterState));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
const DeepCollectionEquality().hash(_activePlans),
|
||||
const DeepCollectionEquality().hash(_draftPlans),
|
||||
isLoading,
|
||||
error,
|
||||
selectedStateIndex,
|
||||
minActivePlanPrice,
|
||||
maxActivePlanPrice,
|
||||
minDraftPlanPrice,
|
||||
maxDraftPlanPrice,
|
||||
activeFilterState,
|
||||
draftFilterState);
|
||||
|
||||
/// Create a copy of MyPlansState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$MyPlansStateImplCopyWith<_$MyPlansStateImpl> get copyWith =>
|
||||
__$$MyPlansStateImplCopyWithImpl<_$MyPlansStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _MyPlansState implements MyPlansState {
|
||||
factory _MyPlansState(
|
||||
{final List<PlanModel> activePlans,
|
||||
final List<PlanModel> draftPlans,
|
||||
final bool isLoading,
|
||||
final String? error,
|
||||
final int selectedStateIndex,
|
||||
final int minActivePlanPrice,
|
||||
final int maxActivePlanPrice,
|
||||
final int minDraftPlanPrice,
|
||||
final int maxDraftPlanPrice,
|
||||
final PlansFilterState activeFilterState,
|
||||
final PlansFilterState draftFilterState}) = _$MyPlansStateImpl;
|
||||
|
||||
@override
|
||||
List<PlanModel> get activePlans;
|
||||
@override
|
||||
List<PlanModel> get draftPlans;
|
||||
@override
|
||||
bool get isLoading;
|
||||
@override
|
||||
String? get error;
|
||||
@override
|
||||
int get selectedStateIndex;
|
||||
@override
|
||||
int get minActivePlanPrice;
|
||||
@override
|
||||
int get maxActivePlanPrice;
|
||||
@override
|
||||
int get minDraftPlanPrice;
|
||||
@override
|
||||
int get maxDraftPlanPrice;
|
||||
@override
|
||||
PlansFilterState get activeFilterState;
|
||||
@override
|
||||
PlansFilterState get draftFilterState;
|
||||
|
||||
/// Create a copy of MyPlansState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$MyPlansStateImplCopyWith<_$MyPlansStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
Reference in New Issue
Block a user