my plans and my diets

This commit is contained in:
Username1548
2024-12-23 15:36:00 +07:00
parent 15a6ff44ef
commit 5ef1f3a660
52 changed files with 3857 additions and 573 deletions

View File

@@ -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({