forked from eatvio/eatvio_app
37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:dio/dio.dart';
|
|
import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
|
|
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
|
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'create_diet_model.freezed.dart';
|
|
|
|
@freezed
|
|
class CreateDietModel with _$CreateDietModel{
|
|
const CreateDietModel._();
|
|
|
|
const factory CreateDietModel({
|
|
String? name,
|
|
String? details,
|
|
String? state,
|
|
int? duration,
|
|
required List<bool> type,
|
|
XFile? image,
|
|
List<List<List<DailySchedule>>>? dailySchedule,
|
|
}) = _CreateDietModel;
|
|
|
|
Future<Map<String, dynamic>> toCreationJson() async => {
|
|
'name': name,
|
|
'duration': duration,
|
|
'state': state,
|
|
'type': type,
|
|
'details': details,
|
|
'image': image != null ? await MultipartFile.fromFile((await ImageCompressUtility.compressFile(File(image!.path))).path, filename: image!.name) : null,
|
|
};
|
|
|
|
Map<String, dynamic> toDailyScheduleCreationJson() => {
|
|
'daily_schedule': dailySchedule,
|
|
};
|
|
} |