feat(diary): Recipe create api route enabled

This commit is contained in:
2024-08-15 16:03:39 +03:00
parent bd9bf4843e
commit aced7e8bcb
15 changed files with 603 additions and 212 deletions

View File

@@ -7,7 +7,7 @@ part 'image.g.dart';
@freezed
class Image with _$Image {
const factory Image({
required String path,
String? path,
}) = _Image;
factory Image.fromJson(Map<String, Object?> json) => _$ImageFromJson(json);

View File

@@ -20,7 +20,7 @@ Image _$ImageFromJson(Map<String, dynamic> json) {
/// @nodoc
mixin _$Image {
String get path => throw _privateConstructorUsedError;
String? get path => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@@ -32,7 +32,7 @@ abstract class $ImageCopyWith<$Res> {
factory $ImageCopyWith(Image value, $Res Function(Image) then) =
_$ImageCopyWithImpl<$Res, Image>;
@useResult
$Res call({String path});
$Res call({String? path});
}
/// @nodoc
@@ -48,13 +48,13 @@ class _$ImageCopyWithImpl<$Res, $Val extends Image>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? path = null,
Object? path = freezed,
}) {
return _then(_value.copyWith(
path: null == path
path: freezed == path
? _value.path
: path // ignore: cast_nullable_to_non_nullable
as String,
as String?,
) as $Val);
}
}
@@ -66,7 +66,7 @@ abstract class _$$ImageImplCopyWith<$Res> implements $ImageCopyWith<$Res> {
__$$ImageImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String path});
$Res call({String? path});
}
/// @nodoc
@@ -80,13 +80,13 @@ class __$$ImageImplCopyWithImpl<$Res>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? path = null,
Object? path = freezed,
}) {
return _then(_$ImageImpl(
path: null == path
path: freezed == path
? _value.path
: path // ignore: cast_nullable_to_non_nullable
as String,
as String?,
));
}
}
@@ -94,13 +94,13 @@ class __$$ImageImplCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$ImageImpl implements _Image {
const _$ImageImpl({required this.path});
const _$ImageImpl({this.path});
factory _$ImageImpl.fromJson(Map<String, dynamic> json) =>
_$$ImageImplFromJson(json);
@override
final String path;
final String? path;
@override
String toString() {
@@ -134,12 +134,12 @@ class _$ImageImpl implements _Image {
}
abstract class _Image implements Image {
const factory _Image({required final String path}) = _$ImageImpl;
const factory _Image({final String? path}) = _$ImageImpl;
factory _Image.fromJson(Map<String, dynamic> json) = _$ImageImpl.fromJson;
@override
String get path;
String? get path;
@override
@JsonKey(ignore: true)
_$$ImageImplCopyWith<_$ImageImpl> get copyWith =>

View File

@@ -7,9 +7,10 @@ part of 'image.dart';
// **************************************************************************
_$ImageImpl _$$ImageImplFromJson(Map<String, dynamic> json) => _$ImageImpl(
path: json['path'] as String,
path: json['path'] as String?,
);
Map<String, dynamic> _$$ImageImplToJson(_$ImageImpl instance) => <String, dynamic>{
Map<String, dynamic> _$$ImageImplToJson(_$ImageImpl instance) =>
<String, dynamic>{
'path': instance.path,
};

View File

@@ -12,6 +12,7 @@ class RecipeModel with _$RecipeModel {
int? id,
required List<Ingredient> ingredients,
required List<Step> steps,
required String title,
required String state,
required String description,
required String type,
@@ -20,6 +21,5 @@ class RecipeModel with _$RecipeModel {
num? cooking_time,
}) = _RecipeModel;
factory RecipeModel.fromJson(Map<String, Object?> json) =>
_$RecipeModelFromJson(json);
factory RecipeModel.fromJson(Map<String, Object?> json) => _$RecipeModelFromJson(json);
}

View File

@@ -23,6 +23,7 @@ mixin _$RecipeModel {
int? get id => throw _privateConstructorUsedError;
List<Ingredient> get ingredients => throw _privateConstructorUsedError;
List<Step> get steps => throw _privateConstructorUsedError;
String get title => throw _privateConstructorUsedError;
String get state => throw _privateConstructorUsedError;
String get description => throw _privateConstructorUsedError;
String get type => throw _privateConstructorUsedError;
@@ -46,6 +47,7 @@ abstract class $RecipeModelCopyWith<$Res> {
{int? id,
List<Ingredient> ingredients,
List<Step> steps,
String title,
String state,
String description,
String type,
@@ -72,6 +74,7 @@ class _$RecipeModelCopyWithImpl<$Res, $Val extends RecipeModel>
Object? id = freezed,
Object? ingredients = null,
Object? steps = null,
Object? title = null,
Object? state = null,
Object? description = null,
Object? type = null,
@@ -92,6 +95,10 @@ class _$RecipeModelCopyWithImpl<$Res, $Val extends RecipeModel>
? _value.steps
: steps // ignore: cast_nullable_to_non_nullable
as List<Step>,
title: null == title
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
state: null == state
? _value.state
: state // ignore: cast_nullable_to_non_nullable
@@ -140,6 +147,7 @@ abstract class _$$RecipeModelImplCopyWith<$Res>
{int? id,
List<Ingredient> ingredients,
List<Step> steps,
String title,
String state,
String description,
String type,
@@ -165,6 +173,7 @@ class __$$RecipeModelImplCopyWithImpl<$Res>
Object? id = freezed,
Object? ingredients = null,
Object? steps = null,
Object? title = null,
Object? state = null,
Object? description = null,
Object? type = null,
@@ -185,6 +194,10 @@ class __$$RecipeModelImplCopyWithImpl<$Res>
? _value._steps
: steps // ignore: cast_nullable_to_non_nullable
as List<Step>,
title: null == title
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
state: null == state
? _value.state
: state // ignore: cast_nullable_to_non_nullable
@@ -220,6 +233,7 @@ class _$RecipeModelImpl implements _RecipeModel {
{this.id,
required final List<Ingredient> ingredients,
required final List<Step> steps,
required this.title,
required this.state,
required this.description,
required this.type,
@@ -250,6 +264,8 @@ class _$RecipeModelImpl implements _RecipeModel {
return EqualUnmodifiableListView(_steps);
}
@override
final String title;
@override
final String state;
@override
@@ -265,7 +281,7 @@ class _$RecipeModelImpl implements _RecipeModel {
@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)';
return 'RecipeModel(id: $id, ingredients: $ingredients, steps: $steps, title: $title, state: $state, description: $description, type: $type, image: $image, video_url: $video_url, cooking_time: $cooking_time)';
}
@override
@@ -277,6 +293,7 @@ class _$RecipeModelImpl implements _RecipeModel {
const DeepCollectionEquality()
.equals(other._ingredients, _ingredients) &&
const DeepCollectionEquality().equals(other._steps, _steps) &&
(identical(other.title, title) || other.title == title) &&
(identical(other.state, state) || other.state == state) &&
(identical(other.description, description) ||
other.description == description) &&
@@ -295,6 +312,7 @@ class _$RecipeModelImpl implements _RecipeModel {
id,
const DeepCollectionEquality().hash(_ingredients),
const DeepCollectionEquality().hash(_steps),
title,
state,
description,
type,
@@ -321,6 +339,7 @@ abstract class _RecipeModel implements RecipeModel {
{final int? id,
required final List<Ingredient> ingredients,
required final List<Step> steps,
required final String title,
required final String state,
required final String description,
required final String type,
@@ -338,6 +357,8 @@ abstract class _RecipeModel implements RecipeModel {
@override
List<Step> get steps;
@override
String get title;
@override
String get state;
@override
String get description;

View File

@@ -15,6 +15,7 @@ _$RecipeModelImpl _$$RecipeModelImplFromJson(Map<String, dynamic> json) =>
steps: (json['steps'] as List<dynamic>)
.map((e) => Step.fromJson(e as Map<String, dynamic>))
.toList(),
title: json['title'] as String,
state: json['state'] as String,
description: json['description'] as String,
type: json['type'] as String,
@@ -28,6 +29,7 @@ Map<String, dynamic> _$$RecipeModelImplToJson(_$RecipeModelImpl instance) =>
'id': instance.id,
'ingredients': instance.ingredients,
'steps': instance.steps,
'title': instance.title,
'state': instance.state,
'description': instance.description,
'type': instance.type,