forked from eatvio/eatvio_app
feat: consultants rating
This commit is contained in:
@@ -9,11 +9,7 @@ part of 'create_diet_service.dart';
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _CreateDietService implements CreateDietService {
|
||||
_CreateDietService(
|
||||
this._dio, {
|
||||
this.baseUrl,
|
||||
this.errorLogger,
|
||||
});
|
||||
_CreateDietService(this._dio, {this.baseUrl, this.errorLogger});
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
@@ -39,81 +35,57 @@ class _CreateDietService implements CreateDietService {
|
||||
final _headers = <String, dynamic>{};
|
||||
final _data = FormData();
|
||||
if (name != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'name',
|
||||
name,
|
||||
));
|
||||
_data.fields.add(MapEntry('name', name));
|
||||
}
|
||||
if (duration != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'duration',
|
||||
duration.toString(),
|
||||
));
|
||||
_data.fields.add(MapEntry('duration', duration.toString()));
|
||||
}
|
||||
if (state != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'state',
|
||||
state,
|
||||
));
|
||||
_data.fields.add(MapEntry('state', state));
|
||||
}
|
||||
if (meatType != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'type[meat]',
|
||||
meatType,
|
||||
));
|
||||
_data.fields.add(MapEntry('type[meat]', meatType));
|
||||
}
|
||||
if (carbType != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'type[carb]',
|
||||
carbType,
|
||||
));
|
||||
_data.fields.add(MapEntry('type[carb]', carbType));
|
||||
}
|
||||
if (vegType != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'type[veg]',
|
||||
vegType,
|
||||
));
|
||||
_data.fields.add(MapEntry('type[veg]', vegType));
|
||||
}
|
||||
if (lightType != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'type[light]',
|
||||
lightType,
|
||||
));
|
||||
_data.fields.add(MapEntry('type[light]', lightType));
|
||||
}
|
||||
if (details != null) {
|
||||
_data.fields.add(MapEntry(
|
||||
'details',
|
||||
details,
|
||||
));
|
||||
_data.fields.add(MapEntry('details', details));
|
||||
}
|
||||
if (image != null) {
|
||||
if (image != null) {
|
||||
_data.files.add(MapEntry(
|
||||
'image',
|
||||
MultipartFile.fromFileSync(
|
||||
image.path,
|
||||
filename: image.path.split(Platform.pathSeparator).last,
|
||||
_data.files.add(
|
||||
MapEntry(
|
||||
'image',
|
||||
MultipartFile.fromFileSync(
|
||||
image.path,
|
||||
filename: image.path.split(Platform.pathSeparator).last,
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
final _options = _setStreamType<CreatedDiet>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
contentType: 'multipart/form-data',
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/diets/create',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
final _options = _setStreamType<CreatedDiet>(
|
||||
Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
contentType: 'multipart/form-data',
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/diets/create',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
|
||||
);
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
|
||||
late CreatedDiet _value;
|
||||
try {
|
||||
@@ -135,22 +107,16 @@ class _CreateDietService implements CreateDietService {
|
||||
final _headers = <String, dynamic>{};
|
||||
final _data = <String, dynamic>{};
|
||||
_data.addAll(model);
|
||||
final _options = _setStreamType<void>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/diets/create/${id}/daily_schedule',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
final _options = _setStreamType<void>(
|
||||
Options(method: 'POST', headers: _headers, extra: _extra)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/diets/create/${id}/daily_schedule',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
|
||||
);
|
||||
await _dio.fetch<void>(_options);
|
||||
}
|
||||
|
||||
@@ -167,10 +133,7 @@ class _CreateDietService implements CreateDietService {
|
||||
return requestOptions;
|
||||
}
|
||||
|
||||
String _combineBaseUrls(
|
||||
String dioBaseUrl,
|
||||
String? baseUrl,
|
||||
) {
|
||||
String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
|
||||
if (baseUrl == null || baseUrl.trim().isEmpty) {
|
||||
return dioBaseUrl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user