forked from eatvio/eatvio_app
plan creation screen added
This commit is contained in:
36
lib/features/create_plan/models/create_plan_model.dart
Normal file
36
lib/features/create_plan/models/create_plan_model.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
|
||||
import 'package:eatvio_app/features/plans/models/plan_pagination_model.dart';
|
||||
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'create_plan_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class CreatePlanModel with _$CreatePlanModel {
|
||||
const CreatePlanModel._();
|
||||
|
||||
const factory CreatePlanModel({
|
||||
String? name,
|
||||
String? details,
|
||||
String? state,
|
||||
int? duration,
|
||||
required List<bool> type,
|
||||
XFile? image,
|
||||
required List<PacketOptions> options,
|
||||
}) = _CreatePlanModel;
|
||||
|
||||
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> toOptionCreationJson() => {'packet1_options': options[0]};
|
||||
Map<String, dynamic> toOptionsCreationJson() => {'packet1_options': options[0], 'packet2_options': options[1], 'packet3_options': options[2]};
|
||||
}
|
||||
Reference in New Issue
Block a user