Files
eatvio_app/lib/features/feed/models/recipes_model.dart
2024-07-31 17:41:38 +03:00

48 lines
1.3 KiB
Dart

import 'package:freezed_annotation/freezed_annotation.dart';
part 'recipes_model.freezed.dart';
part 'recipes_model.g.dart';
@freezed
class Recipes with _$Recipes {
const factory Recipes({
required int id,
required String image,
required String state,
@JsonKey(name: "cooking_time") required int cookingTime,
required List<Ingredient> ingredients,
required String description,
required List<Step> steps,
@JsonKey(name: "video_url") required String videoUrl,
@JsonKey(name: "created_at") required DateTime createdAt,
@JsonKey(name: "updated_at") required DateTime updatedAt,
required String title,
required String type,
required String slug,
@JsonKey(name: "comments_count") required int commentsCount,
}) = _Recipes;
factory Recipes.fromJson(Map<String, Object?> json) => _$RecipesFromJson(json);
}
@freezed
class Ingredient with _$Ingredient {
const factory Ingredient({
required String name,
String? unit,
required String portion,
}) = _Ingredient;
factory Ingredient.fromJson(Map<String, Object?> json) => _$IngredientFromJson(json);
}
@freezed
class Step with _$Step {
const factory Step({
required String image,
required String description,
}) = _Step;
factory Step.fromJson(Map<String, Object?> json) => _$StepFromJson(json);
}