forked from eatvio/eatvio_app
my plans and my diets
This commit is contained in:
@@ -26,7 +26,7 @@ class PlanModel with _$PlanModel {
|
||||
@JsonKey(name: "image") required String image,
|
||||
@JsonKey(name: "duration") required int duration,
|
||||
@JsonKey(name: "state") required String state,
|
||||
@JsonKey(name: "type") required PlanType type,
|
||||
@JsonKey(name: "type", fromJson: planTypeFromJson) required PlanType type,
|
||||
@JsonKey(name: "details") required String details,
|
||||
@JsonKey(name: "packets_count") required int packetsCount,
|
||||
@JsonKey(name: "packet1_options") PacketOptions? packet1Options,
|
||||
@@ -37,12 +37,21 @@ class PlanModel with _$PlanModel {
|
||||
@JsonKey(name: "total_views") required int totalViews,
|
||||
@JsonKey(name: "total_comments") required int totalComments,
|
||||
@JsonKey(name: "is_favorite") required bool isFavorite,
|
||||
@JsonKey(name: "min_price_of_options") required double minPriceOfOptions,
|
||||
@JsonKey(name: "max_price_of_options") required double maxPriceOfOptions,
|
||||
@Default(false) bool wasLikedByMe,
|
||||
}) = _PlanModel;
|
||||
|
||||
factory PlanModel.fromJson(Map<String, dynamic> json) => _$PlanModelFromJson(json);
|
||||
}
|
||||
|
||||
PlanType planTypeFromJson(dynamic json) {
|
||||
if (json is List<dynamic>) {
|
||||
return PlanType(fit: false, slim: false, behavior: false, wellness: false);
|
||||
}
|
||||
return PlanType.fromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PacketOptions with _$PacketOptions {
|
||||
const factory PacketOptions({
|
||||
|
||||
@@ -272,7 +272,7 @@ mixin _$PlanModel {
|
||||
int get duration => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "state")
|
||||
String get state => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "type")
|
||||
@JsonKey(name: "type", fromJson: planTypeFromJson)
|
||||
PlanType get type => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "details")
|
||||
String get details => throw _privateConstructorUsedError;
|
||||
@@ -294,6 +294,10 @@ mixin _$PlanModel {
|
||||
int get totalComments => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "is_favorite")
|
||||
bool get isFavorite => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "min_price_of_options")
|
||||
double get minPriceOfOptions => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "max_price_of_options")
|
||||
double get maxPriceOfOptions => throw _privateConstructorUsedError;
|
||||
bool get wasLikedByMe => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this PlanModel to a JSON map.
|
||||
@@ -318,7 +322,7 @@ abstract class $PlanModelCopyWith<$Res> {
|
||||
@JsonKey(name: "image") String image,
|
||||
@JsonKey(name: "duration") int duration,
|
||||
@JsonKey(name: "state") String state,
|
||||
@JsonKey(name: "type") PlanType type,
|
||||
@JsonKey(name: "type", fromJson: planTypeFromJson) PlanType type,
|
||||
@JsonKey(name: "details") String details,
|
||||
@JsonKey(name: "packets_count") int packetsCount,
|
||||
@JsonKey(name: "packet1_options") PacketOptions? packet1Options,
|
||||
@@ -329,6 +333,8 @@ abstract class $PlanModelCopyWith<$Res> {
|
||||
@JsonKey(name: "total_views") int totalViews,
|
||||
@JsonKey(name: "total_comments") int totalComments,
|
||||
@JsonKey(name: "is_favorite") bool isFavorite,
|
||||
@JsonKey(name: "min_price_of_options") double minPriceOfOptions,
|
||||
@JsonKey(name: "max_price_of_options") double maxPriceOfOptions,
|
||||
bool wasLikedByMe});
|
||||
|
||||
$PlanTypeCopyWith<$Res> get type;
|
||||
@@ -370,6 +376,8 @@ class _$PlanModelCopyWithImpl<$Res, $Val extends PlanModel>
|
||||
Object? totalViews = null,
|
||||
Object? totalComments = null,
|
||||
Object? isFavorite = null,
|
||||
Object? minPriceOfOptions = null,
|
||||
Object? maxPriceOfOptions = null,
|
||||
Object? wasLikedByMe = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
@@ -441,6 +449,14 @@ class _$PlanModelCopyWithImpl<$Res, $Val extends PlanModel>
|
||||
? _value.isFavorite
|
||||
: isFavorite // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
minPriceOfOptions: null == minPriceOfOptions
|
||||
? _value.minPriceOfOptions
|
||||
: minPriceOfOptions // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
maxPriceOfOptions: null == maxPriceOfOptions
|
||||
? _value.maxPriceOfOptions
|
||||
: maxPriceOfOptions // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
wasLikedByMe: null == wasLikedByMe
|
||||
? _value.wasLikedByMe
|
||||
: wasLikedByMe // ignore: cast_nullable_to_non_nullable
|
||||
@@ -526,7 +542,7 @@ abstract class _$$PlanModelImplCopyWith<$Res>
|
||||
@JsonKey(name: "image") String image,
|
||||
@JsonKey(name: "duration") int duration,
|
||||
@JsonKey(name: "state") String state,
|
||||
@JsonKey(name: "type") PlanType type,
|
||||
@JsonKey(name: "type", fromJson: planTypeFromJson) PlanType type,
|
||||
@JsonKey(name: "details") String details,
|
||||
@JsonKey(name: "packets_count") int packetsCount,
|
||||
@JsonKey(name: "packet1_options") PacketOptions? packet1Options,
|
||||
@@ -537,6 +553,8 @@ abstract class _$$PlanModelImplCopyWith<$Res>
|
||||
@JsonKey(name: "total_views") int totalViews,
|
||||
@JsonKey(name: "total_comments") int totalComments,
|
||||
@JsonKey(name: "is_favorite") bool isFavorite,
|
||||
@JsonKey(name: "min_price_of_options") double minPriceOfOptions,
|
||||
@JsonKey(name: "max_price_of_options") double maxPriceOfOptions,
|
||||
bool wasLikedByMe});
|
||||
|
||||
@override
|
||||
@@ -581,6 +599,8 @@ class __$$PlanModelImplCopyWithImpl<$Res>
|
||||
Object? totalViews = null,
|
||||
Object? totalComments = null,
|
||||
Object? isFavorite = null,
|
||||
Object? minPriceOfOptions = null,
|
||||
Object? maxPriceOfOptions = null,
|
||||
Object? wasLikedByMe = null,
|
||||
}) {
|
||||
return _then(_$PlanModelImpl(
|
||||
@@ -652,6 +672,14 @@ class __$$PlanModelImplCopyWithImpl<$Res>
|
||||
? _value.isFavorite
|
||||
: isFavorite // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
minPriceOfOptions: null == minPriceOfOptions
|
||||
? _value.minPriceOfOptions
|
||||
: minPriceOfOptions // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
maxPriceOfOptions: null == maxPriceOfOptions
|
||||
? _value.maxPriceOfOptions
|
||||
: maxPriceOfOptions // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
wasLikedByMe: null == wasLikedByMe
|
||||
? _value.wasLikedByMe
|
||||
: wasLikedByMe // ignore: cast_nullable_to_non_nullable
|
||||
@@ -670,7 +698,7 @@ class _$PlanModelImpl implements _PlanModel {
|
||||
@JsonKey(name: "image") required this.image,
|
||||
@JsonKey(name: "duration") required this.duration,
|
||||
@JsonKey(name: "state") required this.state,
|
||||
@JsonKey(name: "type") required this.type,
|
||||
@JsonKey(name: "type", fromJson: planTypeFromJson) required this.type,
|
||||
@JsonKey(name: "details") required this.details,
|
||||
@JsonKey(name: "packets_count") required this.packetsCount,
|
||||
@JsonKey(name: "packet1_options") this.packet1Options,
|
||||
@@ -681,6 +709,8 @@ class _$PlanModelImpl implements _PlanModel {
|
||||
@JsonKey(name: "total_views") required this.totalViews,
|
||||
@JsonKey(name: "total_comments") required this.totalComments,
|
||||
@JsonKey(name: "is_favorite") required this.isFavorite,
|
||||
@JsonKey(name: "min_price_of_options") required this.minPriceOfOptions,
|
||||
@JsonKey(name: "max_price_of_options") required this.maxPriceOfOptions,
|
||||
this.wasLikedByMe = false});
|
||||
|
||||
factory _$PlanModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -705,7 +735,7 @@ class _$PlanModelImpl implements _PlanModel {
|
||||
@JsonKey(name: "state")
|
||||
final String state;
|
||||
@override
|
||||
@JsonKey(name: "type")
|
||||
@JsonKey(name: "type", fromJson: planTypeFromJson)
|
||||
final PlanType type;
|
||||
@override
|
||||
@JsonKey(name: "details")
|
||||
@@ -738,12 +768,18 @@ class _$PlanModelImpl implements _PlanModel {
|
||||
@JsonKey(name: "is_favorite")
|
||||
final bool isFavorite;
|
||||
@override
|
||||
@JsonKey(name: "min_price_of_options")
|
||||
final double minPriceOfOptions;
|
||||
@override
|
||||
@JsonKey(name: "max_price_of_options")
|
||||
final double maxPriceOfOptions;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool wasLikedByMe;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PlanModel(id: $id, slug: $slug, name: $name, image: $image, duration: $duration, state: $state, type: $type, details: $details, packetsCount: $packetsCount, packet1Options: $packet1Options, packet2Options: $packet2Options, packet3Options: $packet3Options, author: $author, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments, isFavorite: $isFavorite, wasLikedByMe: $wasLikedByMe)';
|
||||
return 'PlanModel(id: $id, slug: $slug, name: $name, image: $image, duration: $duration, state: $state, type: $type, details: $details, packetsCount: $packetsCount, packet1Options: $packet1Options, packet2Options: $packet2Options, packet3Options: $packet3Options, author: $author, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments, isFavorite: $isFavorite, minPriceOfOptions: $minPriceOfOptions, maxPriceOfOptions: $maxPriceOfOptions, wasLikedByMe: $wasLikedByMe)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -777,32 +813,39 @@ class _$PlanModelImpl implements _PlanModel {
|
||||
other.totalComments == totalComments) &&
|
||||
(identical(other.isFavorite, isFavorite) ||
|
||||
other.isFavorite == isFavorite) &&
|
||||
(identical(other.minPriceOfOptions, minPriceOfOptions) ||
|
||||
other.minPriceOfOptions == minPriceOfOptions) &&
|
||||
(identical(other.maxPriceOfOptions, maxPriceOfOptions) ||
|
||||
other.maxPriceOfOptions == maxPriceOfOptions) &&
|
||||
(identical(other.wasLikedByMe, wasLikedByMe) ||
|
||||
other.wasLikedByMe == wasLikedByMe));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
slug,
|
||||
name,
|
||||
image,
|
||||
duration,
|
||||
state,
|
||||
type,
|
||||
details,
|
||||
packetsCount,
|
||||
packet1Options,
|
||||
packet2Options,
|
||||
packet3Options,
|
||||
author,
|
||||
totalLikes,
|
||||
totalViews,
|
||||
totalComments,
|
||||
isFavorite,
|
||||
wasLikedByMe);
|
||||
int get hashCode => Object.hashAll([
|
||||
runtimeType,
|
||||
id,
|
||||
slug,
|
||||
name,
|
||||
image,
|
||||
duration,
|
||||
state,
|
||||
type,
|
||||
details,
|
||||
packetsCount,
|
||||
packet1Options,
|
||||
packet2Options,
|
||||
packet3Options,
|
||||
author,
|
||||
totalLikes,
|
||||
totalViews,
|
||||
totalComments,
|
||||
isFavorite,
|
||||
minPriceOfOptions,
|
||||
maxPriceOfOptions,
|
||||
wasLikedByMe
|
||||
]);
|
||||
|
||||
/// Create a copy of PlanModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -828,7 +871,8 @@ abstract class _PlanModel implements PlanModel {
|
||||
@JsonKey(name: "image") required final String image,
|
||||
@JsonKey(name: "duration") required final int duration,
|
||||
@JsonKey(name: "state") required final String state,
|
||||
@JsonKey(name: "type") required final PlanType type,
|
||||
@JsonKey(name: "type", fromJson: planTypeFromJson)
|
||||
required final PlanType type,
|
||||
@JsonKey(name: "details") required final String details,
|
||||
@JsonKey(name: "packets_count") required final int packetsCount,
|
||||
@JsonKey(name: "packet1_options") final PacketOptions? packet1Options,
|
||||
@@ -839,6 +883,10 @@ abstract class _PlanModel implements PlanModel {
|
||||
@JsonKey(name: "total_views") required final int totalViews,
|
||||
@JsonKey(name: "total_comments") required final int totalComments,
|
||||
@JsonKey(name: "is_favorite") required final bool isFavorite,
|
||||
@JsonKey(name: "min_price_of_options")
|
||||
required final double minPriceOfOptions,
|
||||
@JsonKey(name: "max_price_of_options")
|
||||
required final double maxPriceOfOptions,
|
||||
final bool wasLikedByMe}) = _$PlanModelImpl;
|
||||
|
||||
factory _PlanModel.fromJson(Map<String, dynamic> json) =
|
||||
@@ -863,7 +911,7 @@ abstract class _PlanModel implements PlanModel {
|
||||
@JsonKey(name: "state")
|
||||
String get state;
|
||||
@override
|
||||
@JsonKey(name: "type")
|
||||
@JsonKey(name: "type", fromJson: planTypeFromJson)
|
||||
PlanType get type;
|
||||
@override
|
||||
@JsonKey(name: "details")
|
||||
@@ -896,6 +944,12 @@ abstract class _PlanModel implements PlanModel {
|
||||
@JsonKey(name: "is_favorite")
|
||||
bool get isFavorite;
|
||||
@override
|
||||
@JsonKey(name: "min_price_of_options")
|
||||
double get minPriceOfOptions;
|
||||
@override
|
||||
@JsonKey(name: "max_price_of_options")
|
||||
double get maxPriceOfOptions;
|
||||
@override
|
||||
bool get wasLikedByMe;
|
||||
|
||||
/// Create a copy of PlanModel
|
||||
|
||||
@@ -32,7 +32,7 @@ _$PlanModelImpl _$$PlanModelImplFromJson(Map<String, dynamic> json) =>
|
||||
image: json['image'] as String,
|
||||
duration: (json['duration'] as num).toInt(),
|
||||
state: json['state'] as String,
|
||||
type: PlanType.fromJson(json['type'] as Map<String, dynamic>),
|
||||
type: planTypeFromJson(json['type']),
|
||||
details: json['details'] as String,
|
||||
packetsCount: (json['packets_count'] as num).toInt(),
|
||||
packet1Options: json['packet1_options'] == null
|
||||
@@ -52,6 +52,8 @@ _$PlanModelImpl _$$PlanModelImplFromJson(Map<String, dynamic> json) =>
|
||||
totalViews: (json['total_views'] as num).toInt(),
|
||||
totalComments: (json['total_comments'] as num).toInt(),
|
||||
isFavorite: json['is_favorite'] as bool,
|
||||
minPriceOfOptions: (json['min_price_of_options'] as num).toDouble(),
|
||||
maxPriceOfOptions: (json['max_price_of_options'] as num).toDouble(),
|
||||
wasLikedByMe: json['wasLikedByMe'] as bool? ?? false,
|
||||
);
|
||||
|
||||
@@ -74,6 +76,8 @@ Map<String, dynamic> _$$PlanModelImplToJson(_$PlanModelImpl instance) =>
|
||||
'total_views': instance.totalViews,
|
||||
'total_comments': instance.totalComments,
|
||||
'is_favorite': instance.isFavorite,
|
||||
'min_price_of_options': instance.minPriceOfOptions,
|
||||
'max_price_of_options': instance.maxPriceOfOptions,
|
||||
'wasLikedByMe': instance.wasLikedByMe,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user