forked from eatvio/eatvio_app
feat(recipe): Models, service and repository for eecpe create. Recipe create now uses cubit
This commit is contained in:
14
lib/features/recipes/models/image.dart
Normal file
14
lib/features/recipes/models/image.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'image.freezed.dart';
|
||||
|
||||
part 'image.g.dart';
|
||||
|
||||
@freezed
|
||||
class Image with _$Image {
|
||||
const factory Image({
|
||||
required String path,
|
||||
}) = _Image;
|
||||
|
||||
factory Image.fromJson(Map<String, Object?> json) => _$ImageFromJson(json);
|
||||
}
|
||||
147
lib/features/recipes/models/image.freezed.dart
Normal file
147
lib/features/recipes/models/image.freezed.dart
Normal file
@@ -0,0 +1,147 @@
|
||||
// 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 'image.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');
|
||||
|
||||
Image _$ImageFromJson(Map<String, dynamic> json) {
|
||||
return _Image.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Image {
|
||||
String get path => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$ImageCopyWith<Image> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ImageCopyWith<$Res> {
|
||||
factory $ImageCopyWith(Image value, $Res Function(Image) then) =
|
||||
_$ImageCopyWithImpl<$Res, Image>;
|
||||
@useResult
|
||||
$Res call({String path});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ImageCopyWithImpl<$Res, $Val extends Image>
|
||||
implements $ImageCopyWith<$Res> {
|
||||
_$ImageCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? path = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
path: null == path
|
||||
? _value.path
|
||||
: path // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ImageImplCopyWith<$Res> implements $ImageCopyWith<$Res> {
|
||||
factory _$$ImageImplCopyWith(
|
||||
_$ImageImpl value, $Res Function(_$ImageImpl) then) =
|
||||
__$$ImageImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String path});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ImageImplCopyWithImpl<$Res>
|
||||
extends _$ImageCopyWithImpl<$Res, _$ImageImpl>
|
||||
implements _$$ImageImplCopyWith<$Res> {
|
||||
__$$ImageImplCopyWithImpl(
|
||||
_$ImageImpl _value, $Res Function(_$ImageImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? path = null,
|
||||
}) {
|
||||
return _then(_$ImageImpl(
|
||||
path: null == path
|
||||
? _value.path
|
||||
: path // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$ImageImpl implements _Image {
|
||||
const _$ImageImpl({required this.path});
|
||||
|
||||
factory _$ImageImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$ImageImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String path;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Image(path: $path)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ImageImpl &&
|
||||
(identical(other.path, path) || other.path == path));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, path);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ImageImplCopyWith<_$ImageImpl> get copyWith =>
|
||||
__$$ImageImplCopyWithImpl<_$ImageImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$ImageImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Image implements Image {
|
||||
const factory _Image({required final String path}) = _$ImageImpl;
|
||||
|
||||
factory _Image.fromJson(Map<String, dynamic> json) = _$ImageImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get path;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$ImageImplCopyWith<_$ImageImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
16
lib/features/recipes/models/image.g.dart
Normal file
16
lib/features/recipes/models/image.g.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'image.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$ImageImpl _$$ImageImplFromJson(Map<String, dynamic> json) => _$ImageImpl(
|
||||
path: json['path'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$ImageImplToJson(_$ImageImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'path': instance.path,
|
||||
};
|
||||
18
lib/features/recipes/models/ingredient.dart
Normal file
18
lib/features/recipes/models/ingredient.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'ingredient.freezed.dart';
|
||||
|
||||
part 'ingredient.g.dart';
|
||||
|
||||
@freezed
|
||||
class Ingredient with _$Ingredient {
|
||||
const factory Ingredient({
|
||||
int? id,
|
||||
required String product_name,
|
||||
required String unit,
|
||||
required num portion,
|
||||
}) = _Ingredient;
|
||||
|
||||
factory Ingredient.fromJson(Map<String, Object?> json) =>
|
||||
_$IngredientFromJson(json);
|
||||
}
|
||||
208
lib/features/recipes/models/ingredient.freezed.dart
Normal file
208
lib/features/recipes/models/ingredient.freezed.dart
Normal file
@@ -0,0 +1,208 @@
|
||||
// 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 'ingredient.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');
|
||||
|
||||
Ingredient _$IngredientFromJson(Map<String, dynamic> json) {
|
||||
return _Ingredient.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Ingredient {
|
||||
int? get id => throw _privateConstructorUsedError;
|
||||
String get product_name => throw _privateConstructorUsedError;
|
||||
String get unit => throw _privateConstructorUsedError;
|
||||
num get portion => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$IngredientCopyWith<Ingredient> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $IngredientCopyWith<$Res> {
|
||||
factory $IngredientCopyWith(
|
||||
Ingredient value, $Res Function(Ingredient) then) =
|
||||
_$IngredientCopyWithImpl<$Res, Ingredient>;
|
||||
@useResult
|
||||
$Res call({int? id, String product_name, String unit, num portion});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$IngredientCopyWithImpl<$Res, $Val extends Ingredient>
|
||||
implements $IngredientCopyWith<$Res> {
|
||||
_$IngredientCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? product_name = null,
|
||||
Object? unit = null,
|
||||
Object? portion = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
product_name: null == product_name
|
||||
? _value.product_name
|
||||
: product_name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unit: null == unit
|
||||
? _value.unit
|
||||
: unit // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
portion: null == portion
|
||||
? _value.portion
|
||||
: portion // ignore: cast_nullable_to_non_nullable
|
||||
as num,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$IngredientImplCopyWith<$Res>
|
||||
implements $IngredientCopyWith<$Res> {
|
||||
factory _$$IngredientImplCopyWith(
|
||||
_$IngredientImpl value, $Res Function(_$IngredientImpl) then) =
|
||||
__$$IngredientImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int? id, String product_name, String unit, num portion});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$IngredientImplCopyWithImpl<$Res>
|
||||
extends _$IngredientCopyWithImpl<$Res, _$IngredientImpl>
|
||||
implements _$$IngredientImplCopyWith<$Res> {
|
||||
__$$IngredientImplCopyWithImpl(
|
||||
_$IngredientImpl _value, $Res Function(_$IngredientImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? product_name = null,
|
||||
Object? unit = null,
|
||||
Object? portion = null,
|
||||
}) {
|
||||
return _then(_$IngredientImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
product_name: null == product_name
|
||||
? _value.product_name
|
||||
: product_name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unit: null == unit
|
||||
? _value.unit
|
||||
: unit // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
portion: null == portion
|
||||
? _value.portion
|
||||
: portion // ignore: cast_nullable_to_non_nullable
|
||||
as num,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$IngredientImpl implements _Ingredient {
|
||||
const _$IngredientImpl(
|
||||
{this.id,
|
||||
required this.product_name,
|
||||
required this.unit,
|
||||
required this.portion});
|
||||
|
||||
factory _$IngredientImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$IngredientImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int? id;
|
||||
@override
|
||||
final String product_name;
|
||||
@override
|
||||
final String unit;
|
||||
@override
|
||||
final num portion;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Ingredient(id: $id, product_name: $product_name, unit: $unit, portion: $portion)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$IngredientImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.product_name, product_name) ||
|
||||
other.product_name == product_name) &&
|
||||
(identical(other.unit, unit) || other.unit == unit) &&
|
||||
(identical(other.portion, portion) || other.portion == portion));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, product_name, unit, portion);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$IngredientImplCopyWith<_$IngredientImpl> get copyWith =>
|
||||
__$$IngredientImplCopyWithImpl<_$IngredientImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$IngredientImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Ingredient implements Ingredient {
|
||||
const factory _Ingredient(
|
||||
{final int? id,
|
||||
required final String product_name,
|
||||
required final String unit,
|
||||
required final num portion}) = _$IngredientImpl;
|
||||
|
||||
factory _Ingredient.fromJson(Map<String, dynamic> json) =
|
||||
_$IngredientImpl.fromJson;
|
||||
|
||||
@override
|
||||
int? get id;
|
||||
@override
|
||||
String get product_name;
|
||||
@override
|
||||
String get unit;
|
||||
@override
|
||||
num get portion;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$IngredientImplCopyWith<_$IngredientImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
23
lib/features/recipes/models/ingredient.g.dart
Normal file
23
lib/features/recipes/models/ingredient.g.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'ingredient.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$IngredientImpl _$$IngredientImplFromJson(Map<String, dynamic> json) =>
|
||||
_$IngredientImpl(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
product_name: json['product_name'] as String,
|
||||
unit: json['unit'] as String,
|
||||
portion: json['portion'] as num,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$IngredientImplToJson(_$IngredientImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'product_name': instance.product_name,
|
||||
'unit': instance.unit,
|
||||
'portion': instance.portion,
|
||||
};
|
||||
25
lib/features/recipes/models/recipe_model.dart
Normal file
25
lib/features/recipes/models/recipe_model.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:eatvio_app/features/recipes/models/image.dart';
|
||||
import 'package:eatvio_app/features/recipes/models/ingredient.dart';
|
||||
import 'package:eatvio_app/features/recipes/models/step.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'recipe_model.freezed.dart';
|
||||
part 'recipe_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class RecipeModel with _$RecipeModel {
|
||||
const factory RecipeModel({
|
||||
int? id,
|
||||
required List<Ingredient> ingredients,
|
||||
required List<Step> steps,
|
||||
required String state,
|
||||
required String description,
|
||||
required String type,
|
||||
required Image image,
|
||||
String? video_url,
|
||||
num? cooking_time,
|
||||
}) = _RecipeModel;
|
||||
|
||||
factory RecipeModel.fromJson(Map<String, Object?> json) =>
|
||||
_$RecipeModelFromJson(json);
|
||||
}
|
||||
356
lib/features/recipes/models/recipe_model.freezed.dart
Normal file
356
lib/features/recipes/models/recipe_model.freezed.dart
Normal file
@@ -0,0 +1,356 @@
|
||||
// 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 'recipe_model.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');
|
||||
|
||||
RecipeModel _$RecipeModelFromJson(Map<String, dynamic> json) {
|
||||
return _RecipeModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$RecipeModel {
|
||||
int? get id => throw _privateConstructorUsedError;
|
||||
List<Ingredient> get ingredients => throw _privateConstructorUsedError;
|
||||
List<Step> get steps => throw _privateConstructorUsedError;
|
||||
String get state => throw _privateConstructorUsedError;
|
||||
String get description => throw _privateConstructorUsedError;
|
||||
String get type => throw _privateConstructorUsedError;
|
||||
Image get image => throw _privateConstructorUsedError;
|
||||
String? get video_url => throw _privateConstructorUsedError;
|
||||
num? get cooking_time => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$RecipeModelCopyWith<RecipeModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $RecipeModelCopyWith<$Res> {
|
||||
factory $RecipeModelCopyWith(
|
||||
RecipeModel value, $Res Function(RecipeModel) then) =
|
||||
_$RecipeModelCopyWithImpl<$Res, RecipeModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int? id,
|
||||
List<Ingredient> ingredients,
|
||||
List<Step> steps,
|
||||
String state,
|
||||
String description,
|
||||
String type,
|
||||
Image image,
|
||||
String? video_url,
|
||||
num? cooking_time});
|
||||
|
||||
$ImageCopyWith<$Res> get image;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$RecipeModelCopyWithImpl<$Res, $Val extends RecipeModel>
|
||||
implements $RecipeModelCopyWith<$Res> {
|
||||
_$RecipeModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? ingredients = null,
|
||||
Object? steps = null,
|
||||
Object? state = null,
|
||||
Object? description = null,
|
||||
Object? type = null,
|
||||
Object? image = null,
|
||||
Object? video_url = freezed,
|
||||
Object? cooking_time = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
ingredients: null == ingredients
|
||||
? _value.ingredients
|
||||
: ingredients // ignore: cast_nullable_to_non_nullable
|
||||
as List<Ingredient>,
|
||||
steps: null == steps
|
||||
? _value.steps
|
||||
: steps // ignore: cast_nullable_to_non_nullable
|
||||
as List<Step>,
|
||||
state: null == state
|
||||
? _value.state
|
||||
: state // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
type: null == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
image: null == image
|
||||
? _value.image
|
||||
: image // ignore: cast_nullable_to_non_nullable
|
||||
as Image,
|
||||
video_url: freezed == video_url
|
||||
? _value.video_url
|
||||
: video_url // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
cooking_time: freezed == cooking_time
|
||||
? _value.cooking_time
|
||||
: cooking_time // ignore: cast_nullable_to_non_nullable
|
||||
as num?,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ImageCopyWith<$Res> get image {
|
||||
return $ImageCopyWith<$Res>(_value.image, (value) {
|
||||
return _then(_value.copyWith(image: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$RecipeModelImplCopyWith<$Res>
|
||||
implements $RecipeModelCopyWith<$Res> {
|
||||
factory _$$RecipeModelImplCopyWith(
|
||||
_$RecipeModelImpl value, $Res Function(_$RecipeModelImpl) then) =
|
||||
__$$RecipeModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int? id,
|
||||
List<Ingredient> ingredients,
|
||||
List<Step> steps,
|
||||
String state,
|
||||
String description,
|
||||
String type,
|
||||
Image image,
|
||||
String? video_url,
|
||||
num? cooking_time});
|
||||
|
||||
@override
|
||||
$ImageCopyWith<$Res> get image;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$RecipeModelImplCopyWithImpl<$Res>
|
||||
extends _$RecipeModelCopyWithImpl<$Res, _$RecipeModelImpl>
|
||||
implements _$$RecipeModelImplCopyWith<$Res> {
|
||||
__$$RecipeModelImplCopyWithImpl(
|
||||
_$RecipeModelImpl _value, $Res Function(_$RecipeModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? ingredients = null,
|
||||
Object? steps = null,
|
||||
Object? state = null,
|
||||
Object? description = null,
|
||||
Object? type = null,
|
||||
Object? image = null,
|
||||
Object? video_url = freezed,
|
||||
Object? cooking_time = freezed,
|
||||
}) {
|
||||
return _then(_$RecipeModelImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
ingredients: null == ingredients
|
||||
? _value._ingredients
|
||||
: ingredients // ignore: cast_nullable_to_non_nullable
|
||||
as List<Ingredient>,
|
||||
steps: null == steps
|
||||
? _value._steps
|
||||
: steps // ignore: cast_nullable_to_non_nullable
|
||||
as List<Step>,
|
||||
state: null == state
|
||||
? _value.state
|
||||
: state // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
type: null == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
image: null == image
|
||||
? _value.image
|
||||
: image // ignore: cast_nullable_to_non_nullable
|
||||
as Image,
|
||||
video_url: freezed == video_url
|
||||
? _value.video_url
|
||||
: video_url // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
cooking_time: freezed == cooking_time
|
||||
? _value.cooking_time
|
||||
: cooking_time // ignore: cast_nullable_to_non_nullable
|
||||
as num?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$RecipeModelImpl implements _RecipeModel {
|
||||
const _$RecipeModelImpl(
|
||||
{this.id,
|
||||
required final List<Ingredient> ingredients,
|
||||
required final List<Step> steps,
|
||||
required this.state,
|
||||
required this.description,
|
||||
required this.type,
|
||||
required this.image,
|
||||
this.video_url,
|
||||
this.cooking_time})
|
||||
: _ingredients = ingredients,
|
||||
_steps = steps;
|
||||
|
||||
factory _$RecipeModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$RecipeModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int? id;
|
||||
final List<Ingredient> _ingredients;
|
||||
@override
|
||||
List<Ingredient> get ingredients {
|
||||
if (_ingredients is EqualUnmodifiableListView) return _ingredients;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_ingredients);
|
||||
}
|
||||
|
||||
final List<Step> _steps;
|
||||
@override
|
||||
List<Step> get steps {
|
||||
if (_steps is EqualUnmodifiableListView) return _steps;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_steps);
|
||||
}
|
||||
|
||||
@override
|
||||
final String state;
|
||||
@override
|
||||
final String description;
|
||||
@override
|
||||
final String type;
|
||||
@override
|
||||
final Image image;
|
||||
@override
|
||||
final String? video_url;
|
||||
@override
|
||||
final num? cooking_time;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RecipeModel(id: $id, ingredients: $ingredients, steps: $steps, state: $state, description: $description, type: $type, image: $image, video_url: $video_url, cooking_time: $cooking_time)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$RecipeModelImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._ingredients, _ingredients) &&
|
||||
const DeepCollectionEquality().equals(other._steps, _steps) &&
|
||||
(identical(other.state, state) || other.state == state) &&
|
||||
(identical(other.description, description) ||
|
||||
other.description == description) &&
|
||||
(identical(other.type, type) || other.type == type) &&
|
||||
(identical(other.image, image) || other.image == image) &&
|
||||
(identical(other.video_url, video_url) ||
|
||||
other.video_url == video_url) &&
|
||||
(identical(other.cooking_time, cooking_time) ||
|
||||
other.cooking_time == cooking_time));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
const DeepCollectionEquality().hash(_ingredients),
|
||||
const DeepCollectionEquality().hash(_steps),
|
||||
state,
|
||||
description,
|
||||
type,
|
||||
image,
|
||||
video_url,
|
||||
cooking_time);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RecipeModelImplCopyWith<_$RecipeModelImpl> get copyWith =>
|
||||
__$$RecipeModelImplCopyWithImpl<_$RecipeModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$RecipeModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _RecipeModel implements RecipeModel {
|
||||
const factory _RecipeModel(
|
||||
{final int? id,
|
||||
required final List<Ingredient> ingredients,
|
||||
required final List<Step> steps,
|
||||
required final String state,
|
||||
required final String description,
|
||||
required final String type,
|
||||
required final Image image,
|
||||
final String? video_url,
|
||||
final num? cooking_time}) = _$RecipeModelImpl;
|
||||
|
||||
factory _RecipeModel.fromJson(Map<String, dynamic> json) =
|
||||
_$RecipeModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
int? get id;
|
||||
@override
|
||||
List<Ingredient> get ingredients;
|
||||
@override
|
||||
List<Step> get steps;
|
||||
@override
|
||||
String get state;
|
||||
@override
|
||||
String get description;
|
||||
@override
|
||||
String get type;
|
||||
@override
|
||||
Image get image;
|
||||
@override
|
||||
String? get video_url;
|
||||
@override
|
||||
num? get cooking_time;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$RecipeModelImplCopyWith<_$RecipeModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
37
lib/features/recipes/models/recipe_model.g.dart
Normal file
37
lib/features/recipes/models/recipe_model.g.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'recipe_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$RecipeModelImpl _$$RecipeModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$RecipeModelImpl(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
ingredients: (json['ingredients'] as List<dynamic>)
|
||||
.map((e) => Ingredient.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
steps: (json['steps'] as List<dynamic>)
|
||||
.map((e) => Step.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
state: json['state'] as String,
|
||||
description: json['description'] as String,
|
||||
type: json['type'] as String,
|
||||
image: Image.fromJson(json['image'] as Map<String, dynamic>),
|
||||
video_url: json['video_url'] as String?,
|
||||
cooking_time: json['cooking_time'] as num?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$RecipeModelImplToJson(_$RecipeModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'ingredients': instance.ingredients,
|
||||
'steps': instance.steps,
|
||||
'state': instance.state,
|
||||
'description': instance.description,
|
||||
'type': instance.type,
|
||||
'image': instance.image,
|
||||
'video_url': instance.video_url,
|
||||
'cooking_time': instance.cooking_time,
|
||||
};
|
||||
17
lib/features/recipes/models/step.dart
Normal file
17
lib/features/recipes/models/step.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:eatvio_app/features/recipes/models/image.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'step.freezed.dart';
|
||||
|
||||
part 'step.g.dart';
|
||||
|
||||
@freezed
|
||||
class Step with _$Step {
|
||||
const factory Step({
|
||||
int? id,
|
||||
Image? image,
|
||||
String? description,
|
||||
}) = _Step;
|
||||
|
||||
factory Step.fromJson(Map<String, Object?> json) => _$StepFromJson(json);
|
||||
}
|
||||
199
lib/features/recipes/models/step.freezed.dart
Normal file
199
lib/features/recipes/models/step.freezed.dart
Normal file
@@ -0,0 +1,199 @@
|
||||
// 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 'step.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');
|
||||
|
||||
Step _$StepFromJson(Map<String, dynamic> json) {
|
||||
return _Step.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Step {
|
||||
int? get id => throw _privateConstructorUsedError;
|
||||
Image? get image => throw _privateConstructorUsedError;
|
||||
String? get description => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$StepCopyWith<Step> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $StepCopyWith<$Res> {
|
||||
factory $StepCopyWith(Step value, $Res Function(Step) then) =
|
||||
_$StepCopyWithImpl<$Res, Step>;
|
||||
@useResult
|
||||
$Res call({int? id, Image? image, String? description});
|
||||
|
||||
$ImageCopyWith<$Res>? get image;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$StepCopyWithImpl<$Res, $Val extends Step>
|
||||
implements $StepCopyWith<$Res> {
|
||||
_$StepCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? image = freezed,
|
||||
Object? description = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
image: freezed == image
|
||||
? _value.image
|
||||
: image // ignore: cast_nullable_to_non_nullable
|
||||
as Image?,
|
||||
description: freezed == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ImageCopyWith<$Res>? get image {
|
||||
if (_value.image == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ImageCopyWith<$Res>(_value.image!, (value) {
|
||||
return _then(_value.copyWith(image: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$StepImplCopyWith<$Res> implements $StepCopyWith<$Res> {
|
||||
factory _$$StepImplCopyWith(
|
||||
_$StepImpl value, $Res Function(_$StepImpl) then) =
|
||||
__$$StepImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int? id, Image? image, String? description});
|
||||
|
||||
@override
|
||||
$ImageCopyWith<$Res>? get image;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$StepImplCopyWithImpl<$Res>
|
||||
extends _$StepCopyWithImpl<$Res, _$StepImpl>
|
||||
implements _$$StepImplCopyWith<$Res> {
|
||||
__$$StepImplCopyWithImpl(_$StepImpl _value, $Res Function(_$StepImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? image = freezed,
|
||||
Object? description = freezed,
|
||||
}) {
|
||||
return _then(_$StepImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
image: freezed == image
|
||||
? _value.image
|
||||
: image // ignore: cast_nullable_to_non_nullable
|
||||
as Image?,
|
||||
description: freezed == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$StepImpl implements _Step {
|
||||
const _$StepImpl({this.id, this.image, this.description});
|
||||
|
||||
factory _$StepImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$StepImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int? id;
|
||||
@override
|
||||
final Image? image;
|
||||
@override
|
||||
final String? description;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Step(id: $id, image: $image, description: $description)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$StepImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.image, image) || other.image == image) &&
|
||||
(identical(other.description, description) ||
|
||||
other.description == description));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, image, description);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$StepImplCopyWith<_$StepImpl> get copyWith =>
|
||||
__$$StepImplCopyWithImpl<_$StepImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$StepImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Step implements Step {
|
||||
const factory _Step(
|
||||
{final int? id,
|
||||
final Image? image,
|
||||
final String? description}) = _$StepImpl;
|
||||
|
||||
factory _Step.fromJson(Map<String, dynamic> json) = _$StepImpl.fromJson;
|
||||
|
||||
@override
|
||||
int? get id;
|
||||
@override
|
||||
Image? get image;
|
||||
@override
|
||||
String? get description;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$StepImplCopyWith<_$StepImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
22
lib/features/recipes/models/step.g.dart
Normal file
22
lib/features/recipes/models/step.g.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'step.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$StepImpl _$$StepImplFromJson(Map<String, dynamic> json) => _$StepImpl(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
image: json['image'] == null
|
||||
? null
|
||||
: Image.fromJson(json['image'] as Map<String, dynamic>),
|
||||
description: json['description'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$StepImplToJson(_$StepImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'image': instance.image,
|
||||
'description': instance.description,
|
||||
};
|
||||
Reference in New Issue
Block a user