diff --git a/lib/features/calendar/services/calendar_service.g.dart b/lib/features/calendar/services/calendar_service.g.dart index 903145dc..4dec81f0 100644 --- a/lib/features/calendar/services/calendar_service.g.dart +++ b/lib/features/calendar/services/calendar_service.g.dart @@ -12,47 +12,38 @@ class _CalendarService implements CalendarService { _CalendarService( this._dio, { this.baseUrl, - this.errorLogger, }); final Dio _dio; String? baseUrl; - final ParseErrorLogger? errorLogger; - @override Future> getCalendar() async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _result = await _dio + .fetch>(_setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/calendar/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late List _value; - try { - _value = _result.data! - .map((dynamic i) => CalendarModel.fromJson(i as Map)) - .toList(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/calendar/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + var _value = _result.data! + .map((dynamic i) => CalendarModel.fromJson(i as Map)) + .toList(); return _value; } diff --git a/lib/features/chat/services/chat_service.g.dart b/lib/features/chat/services/chat_service.g.dart index 48a9b016..8f5b8e61 100644 --- a/lib/features/chat/services/chat_service.g.dart +++ b/lib/features/chat/services/chat_service.g.dart @@ -12,46 +12,37 @@ class _ChatService implements ChatService { _ChatService( this._dio, { this.baseUrl, - this.errorLogger, }); final Dio _dio; String? baseUrl; - final ParseErrorLogger? errorLogger; - @override Future> getChatRoom({required String id}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _result = await _dio.fetch>( + _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/chat/show/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, ChatRoomModel.fromJson(v as Map))); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/chat/show/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + var _value = _result.data!.map((k, dynamic v) => + MapEntry(k, ChatRoomModel.fromJson(v as Map))); return _value; } @@ -80,7 +71,7 @@ class _ChatService implements ChatService { filename: i.path.split(Platform.pathSeparator).last, )))); } - final _options = _setStreamType(Options( + await _dio.fetch(_setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -96,8 +87,7 @@ class _ChatService implements ChatService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - ))); - await _dio.fetch(_options); + )))); } @override @@ -109,30 +99,24 @@ class _ChatService implements ChatService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/chat/show/${id}/messages?page=${page}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late ChatMessagesModel _value; - try { - _value = ChatMessagesModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/chat/show/${id}/messages?page=${page}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = ChatMessagesModel.fromJson(_result.data!); return _value; } @@ -142,30 +126,24 @@ class _ChatService implements ChatService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/profile/ws/params', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late WebsocketInfoModel _value; - try { - _value = WebsocketInfoModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/profile/ws/params', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = WebsocketInfoModel.fromJson(_result.data!); return _value; } diff --git a/lib/features/diary/services/diary_service.g.dart b/lib/features/diary/services/diary_service.g.dart index 8c1039c0..aba060cd 100644 --- a/lib/features/diary/services/diary_service.g.dart +++ b/lib/features/diary/services/diary_service.g.dart @@ -12,45 +12,36 @@ class _DiaryService implements DiaryService { _DiaryService( this._dio, { this.baseUrl, - this.errorLogger, }); final Dio _dio; String? baseUrl; - final ParseErrorLogger? errorLogger; - @override Future> getDiaryID() async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _result = await _dio + .fetch>(_setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = _result.data!.cast(); return _value; } @@ -60,31 +51,25 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _result = await _dio.fetch>( + _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${id}/show/', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, DiaryModel.fromJson(v as Map))); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/${id}/show/', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + var _value = _result.data!.map((k, dynamic v) => + MapEntry(k, DiaryModel.fromJson(v as Map))); return _value; } @@ -94,7 +79,7 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio.fetch(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -109,8 +94,7 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - ))); - final _result = await _dio.fetch(_options); + )))); final _value = _result.data; return _value; } @@ -121,34 +105,28 @@ class _DiaryService implements DiaryService { final queryParameters = {r'name': name}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>>(Options( + final _result = await _dio.fetch>( + _setStreamType>>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/filter', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map> _value; - try { - _value = _result.data!.map((k, dynamic v) => MapEntry( - k, - (v as List) - .map((i) => Product.fromJson(i as Map)) - .toList())); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/product_nutritional_values/filter', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + var _value = _result.data!.map((k, dynamic v) => MapEntry( + k, + (v as List) + .map((i) => Product.fromJson(i as Map)) + .toList())); return _value; } @@ -162,30 +140,24 @@ class _DiaryService implements DiaryService { final queryParameters = {r'satiety': satiety}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _result = await _dio + .fetch>(_setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/satiety/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/${diary_id}/meal/${meal_id}/satiety/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = _result.data!.cast(); return _value; } @@ -199,30 +171,24 @@ class _DiaryService implements DiaryService { final queryParameters = {r'mood': mood}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _result = await _dio + .fetch>(_setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/mood/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/${diary_id}/meal/${meal_id}/mood/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = _result.data!.cast(); return _value; } @@ -235,30 +201,24 @@ class _DiaryService implements DiaryService { final queryParameters = {r'wakeup': wakeup}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/wakeup/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late DiaryModel _value; - try { - _value = DiaryModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/${diary_id}/wakeup/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = DiaryModel.fromJson(_result.data!); return _value; } @@ -271,30 +231,24 @@ class _DiaryService implements DiaryService { final queryParameters = {r'retire': retire}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/retire/fill', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late DiaryModel _value; - try { - _value = DiaryModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/${diary_id}/retire/fill', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = DiaryModel.fromJson(_result.data!); return _value; } @@ -314,31 +268,25 @@ class _DiaryService implements DiaryService { }; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _result = await _dio.fetch>( + _setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/${diary_id}/meal/${meal_id}/portions/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.map((k, dynamic v) => - MapEntry(k, Portion.fromJson(v as Map))); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/${diary_id}/meal/${meal_id}/portions/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + var _value = _result.data!.map((k, dynamic v) => + MapEntry(k, Portion.fromJson(v as Map))); return _value; } @@ -359,7 +307,7 @@ class _DiaryService implements DiaryService { filename: photo.path.split(Platform.pathSeparator).last, ), )); - final _options = _setStreamType(Options( + await _dio.fetch(_setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -374,8 +322,7 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - ))); - await _dio.fetch(_options); + )))); } @override @@ -396,30 +343,24 @@ class _DiaryService implements DiaryService { }; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>(Options( + final _result = await _dio.fetch>( + _setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/sendToModeration', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/product_nutritional_values/sendToModeration', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = _result.data!.cast(); return _value; } @@ -429,7 +370,7 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + await _dio.fetch(_setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -444,8 +385,7 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - ))); - await _dio.fetch(_options); + )))); } @override @@ -458,7 +398,7 @@ class _DiaryService implements DiaryService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + await _dio.fetch(_setStreamType(Options( method: 'DELETE', headers: _headers, extra: _extra, @@ -473,8 +413,7 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - ))); - await _dio.fetch(_options); + )))); } @override @@ -491,7 +430,7 @@ class _DiaryService implements DiaryService { }; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + await _dio.fetch(_setStreamType(Options( method: 'DELETE', headers: _headers, extra: _extra, @@ -506,8 +445,7 @@ class _DiaryService implements DiaryService { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - ))); - await _dio.fetch(_options); + )))); } RequestOptions _setStreamType(RequestOptions requestOptions) { diff --git a/lib/features/feed/services/feed_service.g.dart b/lib/features/feed/services/feed_service.g.dart index 36b29923..a0b8a21e 100644 --- a/lib/features/feed/services/feed_service.g.dart +++ b/lib/features/feed/services/feed_service.g.dart @@ -12,45 +12,36 @@ class _FeedService implements FeedService { _FeedService( this._dio, { this.baseUrl, - this.errorLogger, }); final Dio _dio; String? baseUrl; - final ParseErrorLogger? errorLogger; - @override Future getBlocPostList({required int page}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio.fetch>( + _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/blogPosts/index?page=${page}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late FeedBlogPostSettingsModel _value; - try { - _value = FeedBlogPostSettingsModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/blogPosts/index?page=${page}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = FeedBlogPostSettingsModel.fromJson(_result.data!); return _value; } @@ -60,30 +51,24 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipes/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late RecipesPagination _value; - try { - _value = RecipesPagination.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/recipes/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = RecipesPagination.fromJson(_result.data!); return _value; } @@ -93,30 +78,24 @@ class _FeedService implements FeedService { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diets/index', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late DietsPagination _value; - try { - _value = DietsPagination.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diets/index', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = DietsPagination.fromJson(_result.data!); return _value; } diff --git a/lib/features/profile/services/profile_service.g.dart b/lib/features/profile/services/profile_service.g.dart index 79ebdb24..83b66e99 100644 --- a/lib/features/profile/services/profile_service.g.dart +++ b/lib/features/profile/services/profile_service.g.dart @@ -12,45 +12,36 @@ class _ProfileService implements ProfileService { _ProfileService( this._dio, { this.baseUrl, - this.errorLogger, }); final Dio _dio; String? baseUrl; - final ParseErrorLogger? errorLogger; - @override Future getProfileBySlug({required String slug}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = + await _dio.fetch>(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/profile/show/${slug}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Profile _value; - try { - _value = Profile.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/profile/show/${slug}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = Profile.fromJson(_result.data!); return _value; } diff --git a/lib/features/recipes/reporitories/recipe_repository.dart b/lib/features/recipes/reporitories/recipe_repository.dart index 8d2bc57b..e27013c7 100644 --- a/lib/features/recipes/reporitories/recipe_repository.dart +++ b/lib/features/recipes/reporitories/recipe_repository.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:eatvio_app/features/recipes/services/recipe_service.dart'; @@ -19,7 +20,37 @@ class RecipeRepository { Future publishRecipe(RecipeModel recipe) async { try { - return await recipeService.publishRecipe(jsonDecode(jsonEncode(recipe))); + final File file = File(recipe.image ?? ''); + + List> ingredientsMap = recipe.ingredients?.map((ingredient) { + return { + 'name': ingredient!.name, + 'unit': ingredient.unit, + 'portion': ingredient.portion, + }; + }).toList() ?? + []; + + List> stepsMap = recipe.steps?.map((step) { + return { + 'image': File(step?.image ?? ""), + 'description': step?.description ?? "", + }; + }).toList() ?? + []; + print(ingredientsMap); + print(stepsMap); + return await recipeService.publishRecipe( + recipe.type, + recipe.state, + recipe.title, + recipe.description, + recipe.video_url, + ingredientsMap, + stepsMap, + recipe.cooking_time, + file, + ); } catch (e) { rethrow; } diff --git a/lib/features/recipes/services/recipe_service.dart b/lib/features/recipes/services/recipe_service.dart index d68a4e33..d92e6b9c 100644 --- a/lib/features/recipes/services/recipe_service.dart +++ b/lib/features/recipes/services/recipe_service.dart @@ -1,3 +1,6 @@ +import 'dart:convert'; +import 'dart:io'; + import 'package:dio/dio.dart'; import 'package:eatvio_app/features/recipes/models/recipe_model.dart'; import 'package:retrofit/retrofit.dart'; @@ -16,7 +19,17 @@ abstract class RecipeService { Future>> getInputProduct(@Query('name') String name); @POST('/api/recipes/create') - Future publishRecipe(@Part() Map recipe); + Future publishRecipe( + @Part() String? type, + @Part() String? state, + @Part() String? title, + @Part() String? description, + @Part() String? video_url, + @Part() List> ingredients, + @Part() List> steps, + @Part() int? cooking_time, + @Part() File image, + ); @POST('/api/recipes/update/{id}') Future editRecipe(@Part() Map recipe, String id); diff --git a/lib/features/recipes/services/recipe_service.g.dart b/lib/features/recipes/services/recipe_service.g.dart index c28edc26..a1fb1eb5 100644 --- a/lib/features/recipes/services/recipe_service.g.dart +++ b/lib/features/recipes/services/recipe_service.g.dart @@ -12,45 +12,36 @@ class _RecipeService implements RecipeService { _RecipeService( this._dio, { this.baseUrl, - this.errorLogger, }); final Dio _dio; String? baseUrl; - final ParseErrorLogger? errorLogger; - @override Future getRecipe(String id) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipes/show/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late RecipeModel _value; - try { - _value = RecipeModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/recipes/show/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = RecipeModel.fromJson(_result.data!); return _value; } @@ -60,67 +51,115 @@ class _RecipeService implements RecipeService { final queryParameters = {r'name': name}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType>>(Options( + final _result = await _dio.fetch>( + _setStreamType>>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/filter', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map> _value; - try { - _value = _result.data!.map((k, dynamic v) => MapEntry( - k, - (v as List) - .map((i) => Product.fromJson(i as Map)) - .toList())); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/diary/product_nutritional_values/filter', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + var _value = _result.data!.map((k, dynamic v) => MapEntry( + k, + (v as List) + .map((i) => Product.fromJson(i as Map)) + .toList())); return _value; } @override - Future publishRecipe(Map recipe) async { + Future publishRecipe( + String? type, + String? state, + String? title, + String? description, + String? video_url, + List> ingredients, + List> steps, + int? cooking_time, + File image, + ) async { final _extra = {}; final queryParameters = {}; + queryParameters.removeWhere((k, v) => v == null); final _headers = {}; - final _data = FormData.fromMap(recipe); - final _options = _setStreamType(Options( + final _data = FormData(); + if (type != null) { + _data.fields.add(MapEntry( + 'type', + type, + )); + } + if (state != null) { + _data.fields.add(MapEntry( + 'state', + state, + )); + } + if (title != null) { + _data.fields.add(MapEntry( + 'title', + title, + )); + } + if (description != null) { + _data.fields.add(MapEntry( + 'description', + description, + )); + } + if (video_url != null) { + _data.fields.add(MapEntry( + 'video_url', + video_url, + )); + } + ingredients.forEach((i) { + _data.fields.add(MapEntry('ingredients', jsonEncode(i))); + }); + steps.forEach((i) { + _data.fields.add(MapEntry('steps', jsonEncode(i))); + }); + if (cooking_time != null) { + _data.fields.add(MapEntry( + 'cooking_time', + cooking_time.toString(), + )); + } + _data.files.add(MapEntry( + 'image', + MultipartFile.fromFileSync( + image.path, + filename: image.path.split(Platform.pathSeparator).last, + ), + )); + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipes/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late RecipeModel _value; - try { - _value = RecipeModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/recipes/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = RecipeModel.fromJson(_result.data!); return _value; } @@ -133,30 +172,24 @@ class _RecipeService implements RecipeService { final queryParameters = {}; final _headers = {}; final _data = FormData.fromMap(recipe); - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipes/update/{id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late RecipeModel _value; - try { - _value = RecipeModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/recipes/update/{id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = RecipeModel.fromJson(_result.data!); return _value; } diff --git a/lib/features/registration/services/registration_service.g.dart b/lib/features/registration/services/registration_service.g.dart index 4aaccede..9820fd33 100644 --- a/lib/features/registration/services/registration_service.g.dart +++ b/lib/features/registration/services/registration_service.g.dart @@ -12,15 +12,12 @@ class _RegistrationService implements RegistrationService { _RegistrationService( this._dio, { this.baseUrl, - this.errorLogger, }); final Dio _dio; String? baseUrl; - final ParseErrorLogger? errorLogger; - @override Future> register( {required Map sheet}) async { @@ -29,30 +26,24 @@ class _RegistrationService implements RegistrationService { final _headers = {}; final _data = {}; _data.addAll(sheet); - final _options = _setStreamType>(Options( + final _result = await _dio.fetch>( + _setStreamType>(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/register', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late Map _value; - try { - _value = _result.data!.cast(); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/register', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = _result.data!.cast(); return _value; } @@ -62,30 +53,24 @@ class _RegistrationService implements RegistrationService { final queryParameters = {r'user_address': query}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/location_by_address', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late LocationModel _value; - try { - _value = LocationModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/location_by_address', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = LocationModel.fromJson(_result.data!); return _value; } @@ -101,30 +86,24 @@ class _RegistrationService implements RegistrationService { }; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _result = await _dio + .fetch>(_setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/location_by_coordinate', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - ))); - final _result = await _dio.fetch>(_options); - late LocationModel _value; - try { - _value = LocationModel.fromJson(_result.data!); - } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); - rethrow; - } + .compose( + _dio.options, + '/api/location_by_coordinate', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + final _value = LocationModel.fromJson(_result.data!); return _value; } diff --git a/lib/locator_service.dart b/lib/locator_service.dart index e580c725..1e99c3c9 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -69,6 +69,10 @@ Future init() async { () => Dio( BaseOptions( baseUrl: baseUrl, + headers: { + 'accept': 'application/json', + 'content-type': 'application/json', + }, ), ), ); diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart index d10b70ab..03b9f4b2 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -1,23 +1,26 @@ import 'dart:convert'; -import 'dart:math'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:carousel_slider_plus/carousel_slider_plus.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_subtitle.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; -import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:go_router/go_router.dart'; import 'package:http/http.dart' as http; import 'package:image_picker/image_picker.dart'; -import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; import 'bloc/my_profile_bloc.dart'; import 'models/my_profile_model.dart'; class MyProfileScreen extends StatelessWidget { + int valuteToInt(String value) { + // Преобразование строки в целое число + return int.tryParse(value) ?? 0; // Возвращает 0, если преобразование не удалось + } + static Widget builder(BuildContext context) { return BlocProvider( create: (context) => MyProfileBloc( @@ -192,7 +195,7 @@ class MyProfileScreen extends StatelessWidget { _buildCarousel(BuildContext contex, MyProfileLoadedState state) { return CarouselSlider( - options: CarouselOptions(height: 340), + options: CarouselOptions(height: 370), items: [1, 2, 3].map((chartType) { return Builder( builder: (BuildContext context) { @@ -249,7 +252,7 @@ class MyProfileScreen extends StatelessWidget { ), ), SizedBox(height: 30.v), - _buildCircumferenceChart(context, state.circumferences, state.chartDates), + // _buildCircumferenceChart(context, state.circumferences, state.chartDates), _buildChartLegend(), ], ), @@ -295,355 +298,35 @@ class MyProfileScreen extends StatelessWidget { ); } - _buildChart(BuildContext context, List chartPoints, List? dates) { - List spots = []; - for (int i = 0; i < 4; i++) { - spots.add( - FlSpot((i * 10 / 10) + 1, chartPoints[i]), - ); + Widget _buildChart(BuildContext context, List chartPoints, List? dates) { + // Проверяем, что у нас есть 4 элемента в обоих списках + if (chartPoints.length != 4 || (dates != null && dates.length != 4)) { + return Center(child: Text('Должно быть ровно 4 точки и 4 даты.')); } - Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List? dates) { - if (value % 1 != 0) { - return Container(); - } - final style = TextStyle( - color: Colors.blue, - fontWeight: FontWeight.bold, - fontSize: min(13, 13 * chartWidth / 300), - ); - int index = value.toInt(); - if (index >= 0 && index < dates!.length) { - // Проверка на допустимый индекс в массиве dates - String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index])); - return SideTitleWidget( - axisSide: meta.axisSide, - space: 16, - child: Text(formattedDate, style: style), - ); - } else { - return Container(); - } - } + // Преобразуем данные в список точек для графика + List chartData = List.generate(4, (index) { + return ChartData(dates![index], chartPoints[index]); + }); - Widget leftTitleWidgets(double value, TitleMeta meta, double chartWidth) { - final style = TextStyle( - color: Colors.blue, - fontWeight: FontWeight.bold, - fontSize: min(18, 18 * chartWidth / 300), - ); - return SideTitleWidget( - axisSide: meta.axisSide, - space: 16, - child: Text(meta.formattedValue, style: style), - ); - } - - return Padding( - padding: const EdgeInsets.only( - left: 12, - right: 20, - ), - child: AspectRatio( - aspectRatio: 1, - child: LayoutBuilder( - builder: (context, constraints) { - return LineChart( - LineChartData( - lineTouchData: LineTouchData( - touchTooltipData: LineTouchTooltipData( - maxContentWidth: 100, - // tooltipBgColor: Colors.black, - getTooltipItems: mapSpots(), - ), - handleBuiltInTouches: true, - getTouchLineStart: (data, index) => 0, - ), - lineBarsData: [ - LineChartBarData( - color: Colors.pink, - spots: spots, - isCurved: true, - isStrokeCapRound: true, - barWidth: 3, - belowBarData: BarAreaData( - show: false, - ), - dotData: const FlDotData(show: false), - ), - ], - minY: chartPoints.reduce((value, element) => value < element ? value : element), - maxY: chartPoints.reduce((value, element) => value > element ? value : element), - minX: 1, - maxX: 4, - titlesData: FlTitlesData( - leftTitles: AxisTitles( - sideTitles: SideTitles( - showTitles: true, - getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth), - reservedSize: 56, - ), - drawBelowEverything: true, - ), - rightTitles: const AxisTitles( - sideTitles: SideTitles(showTitles: false), - ), - bottomTitles: AxisTitles( - sideTitles: SideTitles( - showTitles: true, - getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates), - reservedSize: 36, - interval: 1, - ), - drawBelowEverything: true, - ), - topTitles: const AxisTitles( - sideTitles: SideTitles(showTitles: false), - ), - ), - gridData: FlGridData( - show: true, - drawHorizontalLine: true, - drawVerticalLine: true, - horizontalInterval: 1.5, - verticalInterval: 5, - checkToShowHorizontalLine: valuteToInt(), - getDrawingHorizontalLine: (_) => FlLine( - color: Colors.blue.withOpacity(1), - dashArray: [8, 2], - strokeWidth: 0.8, - ), - getDrawingVerticalLine: (_) => FlLine( - color: Colors.blue.withOpacity(1), - dashArray: [8, 2], - strokeWidth: 0.8, - ), - checkToShowVerticalLine: valuteToInt(), - ), - borderData: FlBorderData(show: false), - ), - ); - }, - ), + return Container( + height: 300, // Задайте нужную высоту для графика + child: SfCartesianChart( + title: ChartTitle(text: 'График значений'), + primaryXAxis: CategoryAxis(), + series: >[ + // Изменяем на CartesianSeries + LineSeries( + dataSource: chartData, + xValueMapper: (ChartData data, _) => data.date, + yValueMapper: (ChartData data, _) => data.value, + dataLabelSettings: DataLabelSettings(isVisible: true), + ), + ], ), ); } - valuteToInt() { - return (value) { - return value.toInt() == 0; - }; - } - - List Function(List) mapSpots() { - return (touchedSpots) { - return touchedSpots.map((LineBarSpot touchedSpot) { - final textStyle = TextStyle( - color: touchedSpot.bar.gradient?.colors[0] ?? touchedSpot.bar.color, - fontWeight: FontWeight.bold, - fontSize: 14, - ); - return LineTooltipItem( - '${touchedSpot.x}, ${touchedSpot.y.toStringAsFixed(2)}', - textStyle, - ); - }).toList(); - }; - } - - _buildCircumferenceChart(BuildContext context, chartPoints, List? dates) { -// Определение осей графика - final chestCircumferences = chartPoints.values.map((e) => e['chest_circumference']).toList(); - List spotsChest = []; - for (int i = 0; i < 4; i++) { - chestCircumferences[i] = chestCircumferences[i] * 10 / 10; - spotsChest.add( - FlSpot((i * 10 / 10) + 1, chestCircumferences[i] * 10 / 10), - ); - } - final waistCircumferences = chartPoints.values.map((e) => e['waist_circumference']).toList(); - List spotsWaist = []; - for (int i = 0; i < 4; i++) { - waistCircumferences[i] = waistCircumferences[i] * 10 / 10; - spotsWaist.add( - FlSpot((i * 10 / 10) + 1, waistCircumferences[i] * 10 / 10), - ); - } - final hipCircumferences = chartPoints.values.map((e) => e['hip_circumference']).toList(); - List spotsHip = []; - for (int i = 0; i < 4; i++) { - hipCircumferences[i] = hipCircumferences[i] * 10 / 10; - spotsHip.add( - FlSpot((i * 10 / 10) + 1, hipCircumferences[i]), - ); - } - - final allCircumferences = [...chestCircumferences, ...hipCircumferences, ...waistCircumferences]; - - Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth, List? dates) { - if (value % 1 != 0) { - return Container(); - } - final style = TextStyle( - color: Colors.blue, - fontWeight: FontWeight.bold, - fontSize: min(13, 13 * chartWidth / 300), - ); - int index = value.toInt(); - if (index >= 0 && index < dates!.length) { - // Проверка на допустимый индекс в массиве dates - String formattedDate = DateFormat('dd.MM').format(DateTime.parse(dates[index])); - return SideTitleWidget( - axisSide: meta.axisSide, - space: 16, - child: Text(formattedDate, style: style), - ); - } else { - return Container(); - } - } - - Widget leftTitleWidgets(double value, TitleMeta meta, double chartWidth) { - final style = TextStyle( - color: Colors.blue, - fontWeight: FontWeight.bold, - fontSize: min(18, 18 * chartWidth / 300), - ); - return SideTitleWidget( - axisSide: meta.axisSide, - space: 16, - child: Text(meta.formattedValue, style: style), - ); - } - - return Padding( - padding: const EdgeInsets.only( - left: 12, - right: 20, - ), - child: AspectRatio( - aspectRatio: 1, - child: LayoutBuilder( - builder: (context, constraints) { - return LineChart( - LineChartData( - lineTouchData: LineTouchData( - touchTooltipData: LineTouchTooltipData( - maxContentWidth: 100, - // tooltipBgColor: Colors.black, - getTooltipItems: mapTouchedSpots(), - ), - handleBuiltInTouches: true, - getTouchLineStart: (data, index) => 0, - ), - lineBarsData: [ - LineChartBarData( - color: Colors.pink, - spots: spotsChest, - isCurved: true, - isStrokeCapRound: true, - barWidth: 3, - belowBarData: BarAreaData( - show: false, - ), - dotData: const FlDotData(show: false), - ), - LineChartBarData( - color: Colors.green, - spots: spotsWaist, - isCurved: true, - isStrokeCapRound: true, - barWidth: 3, - belowBarData: BarAreaData( - show: false, - ), - dotData: const FlDotData(show: false), - ), - LineChartBarData( - color: Colors.purple, - spots: spotsHip, - isCurved: true, - isStrokeCapRound: true, - barWidth: 3, - belowBarData: BarAreaData( - show: false, - ), - dotData: const FlDotData(show: false), - ), - ], - minY: allCircumferences.reduce((value, element) => value < element ? value : element), - maxY: allCircumferences.reduce((value, element) => value > element ? value : element), - minX: 1, - maxX: 4, - titlesData: FlTitlesData( - leftTitles: AxisTitles( - sideTitles: SideTitles( - showTitles: true, - getTitlesWidget: (value, meta) => leftTitleWidgets(value, meta, constraints.maxWidth), - reservedSize: 56, - ), - drawBelowEverything: true, - ), - rightTitles: const AxisTitles( - sideTitles: SideTitles(showTitles: false), - ), - bottomTitles: AxisTitles( - sideTitles: SideTitles( - showTitles: true, - getTitlesWidget: (value, meta) => bottomTitleWidgets(value, meta, constraints.maxWidth, dates), - reservedSize: 36, - interval: 1, - ), - drawBelowEverything: true, - ), - topTitles: const AxisTitles( - sideTitles: SideTitles(showTitles: false), - ), - ), - gridData: FlGridData( - show: true, - drawHorizontalLine: true, - drawVerticalLine: true, - horizontalInterval: 1.5, - verticalInterval: 5, - checkToShowHorizontalLine: valuteToInt(), - getDrawingHorizontalLine: (_) => FlLine( - color: Colors.blue.withOpacity(1), - dashArray: [8, 2], - strokeWidth: 0.8, - ), - getDrawingVerticalLine: (_) => FlLine( - color: Colors.blue.withOpacity(1), - dashArray: [8, 2], - strokeWidth: 0.8, - ), - checkToShowVerticalLine: valuteToInt(), - ), - borderData: FlBorderData(show: false), - ), - ); - }, - ), - ), - ); - } - - List Function(List) mapTouchedSpots() { - return (touchedSpots) { - return touchedSpots.map((LineBarSpot touchedSpot) { - final textStyle = TextStyle( - color: touchedSpot.bar.gradient?.colors[0] ?? touchedSpot.bar.color, - fontWeight: FontWeight.bold, - fontSize: 14, - ); - return LineTooltipItem( - '${touchedSpot.x}, ${touchedSpot.y.toStringAsFixed(2)}', - textStyle, - ); - }).toList(); - }; - } - /// Section Widget _buildPlans(BuildContext context, List? plans, List? imagePaths, List? states) { return Padding( @@ -962,3 +645,16 @@ class MyProfileScreen extends StatelessWidget { }; } } + +class ChartData { + final String date; + final double value; + + ChartData(this.date, this.value); + + valuteToInt() { + return (value) { + return value.toInt() == 0; + }; + } +}