diff --git a/lib/features/diary/models/diary_model.dart b/lib/features/diary/models/diary_model.dart index 079d483f..3a899363 100644 --- a/lib/features/diary/models/diary_model.dart +++ b/lib/features/diary/models/diary_model.dart @@ -10,7 +10,7 @@ class DiaryModel with _$DiaryModel { required int id, required DateTime date, required int closed, - required List? meals, + required List meals, String? comment, DateTime? wakeup, DateTime? retire, diff --git a/lib/features/diary/models/diary_model.freezed.dart b/lib/features/diary/models/diary_model.freezed.dart index 2c612ec8..3fe59e15 100644 --- a/lib/features/diary/models/diary_model.freezed.dart +++ b/lib/features/diary/models/diary_model.freezed.dart @@ -23,7 +23,7 @@ mixin _$DiaryModel { int get id => throw _privateConstructorUsedError; DateTime get date => throw _privateConstructorUsedError; int get closed => throw _privateConstructorUsedError; - List? get meals => throw _privateConstructorUsedError; + List get meals => throw _privateConstructorUsedError; String? get comment => throw _privateConstructorUsedError; DateTime? get wakeup => throw _privateConstructorUsedError; DateTime? get retire => throw _privateConstructorUsedError; @@ -44,7 +44,7 @@ abstract class $DiaryModelCopyWith<$Res> { {int id, DateTime date, int closed, - List? meals, + List meals, String? comment, DateTime? wakeup, DateTime? retire}); @@ -66,7 +66,7 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> Object? id = null, Object? date = null, Object? closed = null, - Object? meals = freezed, + Object? meals = null, Object? comment = freezed, Object? wakeup = freezed, Object? retire = freezed, @@ -84,10 +84,10 @@ class _$DiaryModelCopyWithImpl<$Res, $Val extends DiaryModel> ? _value.closed : closed // ignore: cast_nullable_to_non_nullable as int, - meals: freezed == meals + meals: null == meals ? _value.meals : meals // ignore: cast_nullable_to_non_nullable - as List?, + as List, comment: freezed == comment ? _value.comment : comment // ignore: cast_nullable_to_non_nullable @@ -116,7 +116,7 @@ abstract class _$$DiaryModelImplCopyWith<$Res> {int id, DateTime date, int closed, - List? meals, + List meals, String? comment, DateTime? wakeup, DateTime? retire}); @@ -136,7 +136,7 @@ class __$$DiaryModelImplCopyWithImpl<$Res> Object? id = null, Object? date = null, Object? closed = null, - Object? meals = freezed, + Object? meals = null, Object? comment = freezed, Object? wakeup = freezed, Object? retire = freezed, @@ -154,10 +154,10 @@ class __$$DiaryModelImplCopyWithImpl<$Res> ? _value.closed : closed // ignore: cast_nullable_to_non_nullable as int, - meals: freezed == meals + meals: null == meals ? _value._meals : meals // ignore: cast_nullable_to_non_nullable - as List?, + as List, comment: freezed == comment ? _value.comment : comment // ignore: cast_nullable_to_non_nullable @@ -181,7 +181,7 @@ class _$DiaryModelImpl implements _DiaryModel { {required this.id, required this.date, required this.closed, - required final List? meals, + required final List meals, this.comment, this.wakeup, this.retire}) @@ -196,14 +196,12 @@ class _$DiaryModelImpl implements _DiaryModel { final DateTime date; @override final int closed; - final List? _meals; + final List _meals; @override - List? get meals { - final value = _meals; - if (value == null) return null; + List get meals { if (_meals is EqualUnmodifiableListView) return _meals; // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); + return EqualUnmodifiableListView(_meals); } @override @@ -256,7 +254,7 @@ abstract class _DiaryModel implements DiaryModel { {required final int id, required final DateTime date, required final int closed, - required final List? meals, + required final List meals, final String? comment, final DateTime? wakeup, final DateTime? retire}) = _$DiaryModelImpl; @@ -271,7 +269,7 @@ abstract class _DiaryModel implements DiaryModel { @override int get closed; @override - List? get meals; + List get meals; @override String? get comment; @override diff --git a/lib/features/diary/models/diary_model.g.dart b/lib/features/diary/models/diary_model.g.dart index fc9f7d0e..1a13c7d5 100644 --- a/lib/features/diary/models/diary_model.g.dart +++ b/lib/features/diary/models/diary_model.g.dart @@ -11,8 +11,8 @@ _$DiaryModelImpl _$$DiaryModelImplFromJson(Map json) => id: (json['id'] as num).toInt(), date: DateTime.parse(json['date'] as String), closed: (json['closed'] as num).toInt(), - meals: (json['meals'] as List?) - ?.map((e) => Meal.fromJson(e as Map)) + meals: (json['meals'] as List) + .map((e) => Meal.fromJson(e as Map)) .toList(), comment: json['comment'] as String?, wakeup: json['wakeup'] == null diff --git a/lib/features/diary/presentation/bloc/diary_bloc.dart b/lib/features/diary/presentation/bloc/diary_bloc.dart index f2d0b7f6..9cc1b778 100644 --- a/lib/features/diary/presentation/bloc/diary_bloc.dart +++ b/lib/features/diary/presentation/bloc/diary_bloc.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'package:eatvio_app/features/diary/models/diary_model.dart'; import 'package:eatvio_app/features/diary/models/meal.dart'; import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; import 'package:intl/intl.dart'; @@ -55,8 +56,13 @@ class DiaryBloc extends Bloc { try { Map data = await diaryRepository.getDiaryID(); final int? diaryID = data['id']; + final DiaryModel diary = await diaryRepository.getDiary(diaryID ?? 45); + final Meal currentMeal = diary.meals[0]; emit(DiaryState.loaded( - diary: await diaryRepository.getDiary(diaryID ?? 45), + diary: diary, + currentMeal: currentMeal, + portions: currentMeal.portions, + photos: currentMeal.photos, commentController: TextEditingController(), productNameController: TextEditingController(), productQuantityController: TextEditingController(), @@ -69,8 +75,9 @@ class DiaryBloc extends Bloc { moodExpanded: false, isLoading: false, isAdded: false, - recommendedChartValues: [0, 0, 0, 0], - consumedChartValues: [0, 0, 0, 0])); + autocompleteList: [], + recommendedChartValues: [1, 1, 1, 1], + consumedChartValues: [1, 1, 1, 1])); } catch (e) { emit(DiaryState.error(errorMessage: e.toString())); print(e); @@ -143,13 +150,13 @@ class DiaryBloc extends Bloc { // Отправляем данные по HTTP маршруту и ждем ответ var response = await sendSatietyData( event.selectedElement, - currentState.currentMeal?.id, + currentState.currentMeal.id, currentState.diary.id, ); if (response.statusCode == 200) { print( - 'Satiety change success! meal_id: ${currentState.currentMeal?.id}, mood: ${event.selectedElement}', + 'Satiety change success! meal_id: ${currentState.currentMeal.id}, mood: ${event.selectedElement}', ); emit(updatedState); // Передаем обновленное состояние в emit } @@ -189,13 +196,13 @@ class DiaryBloc extends Bloc { // Отправляем данные по HTTP маршруту и ждем ответ var response = await sendMoodData( event.selectedElement, - currentState.currentMeal?.id, + currentState.currentMeal.id, currentState.diary.id, ); if (response.statusCode == 200) { print( - 'Mood change success! meal_id: ${currentState.currentMeal?.id}, mood: ${event.selectedElement}', + 'Mood change success! meal_id: ${currentState.currentMeal.id}, mood: ${event.selectedElement}', ); emit(updatedState); // Передаем обновленное состояние в emit } @@ -359,8 +366,8 @@ class DiaryBloc extends Bloc { ) async { if (state is DiaryStateLoaded) { var currentState = state as DiaryStateLoaded; - Meal? meal = currentState.diary.meals! - .firstWhere((meal) => meal.id == event.value); + Meal? meal = + currentState.diary.meals.firstWhere((meal) => meal.id == event.value); DiaryStateLoaded updatedState = currentState.copyWith( currentMeal: event.value, @@ -431,7 +438,7 @@ class DiaryBloc extends Bloc { currentState.productNameController?.text, currentState.portionController?.id == 0 ? 'pcs' : 'gr', int.parse(currentState.productQuantityController!.text), - currentState.currentMeal!.id, + currentState.currentMeal.id, currentState.diary.id, ); @@ -523,7 +530,7 @@ class DiaryBloc extends Bloc { var currentState = state as DiaryStateLoaded; int? mealId = - currentState.currentMeal?.id; // Rename id to mealId for clarity + currentState.currentMeal.id; // Rename id to mealId for clarity var response = await sendRemovePortion( event.portionId, @@ -570,7 +577,7 @@ class DiaryBloc extends Bloc { var response = await sendRemovePhoto( event.path, event.photoID, - currentState.currentMeal?.id, + currentState.currentMeal.id, currentState.diary.id, ); print(response.statusCode); @@ -668,7 +675,7 @@ class DiaryBloc extends Bloc { await uploadImageToServer( event.image.path, currentState.diary.id, - currentState.currentMeal!.id, + currentState.currentMeal.id, ); await reloadScreen(event, emit); } diff --git a/lib/features/diary/presentation/bloc/diary_state.dart b/lib/features/diary/presentation/bloc/diary_state.dart index b9f26953..4f324479 100644 --- a/lib/features/diary/presentation/bloc/diary_state.dart +++ b/lib/features/diary/presentation/bloc/diary_state.dart @@ -18,23 +18,23 @@ abstract class DiaryState with _$DiaryState { const factory DiaryState.loaded({ required DiaryModel diary, String? diaryDate, - List? autocompleteList, + required List autocompleteList, required List recommendedChartValues, required List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + required List portions, + required List photos, + required Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, TimeOfDay? mealTimeController, - required TextEditingController? commentController, - required TextEditingController? productNameController, - required TextEditingController? productQuantityController, - required TextEditingController? caloriesController, - required TextEditingController? fatsController, - required TextEditingController? proteinsController, - required TextEditingController? carbsController, + required TextEditingController commentController, + required TextEditingController productNameController, + required TextEditingController productQuantityController, + required TextEditingController caloriesController, + required TextEditingController fatsController, + required TextEditingController proteinsController, + required TextEditingController carbsController, int? selectedMood, int? selectedSatiety, required bool wakeupExpanded, diff --git a/lib/features/diary/presentation/bloc/diary_state.freezed.dart b/lib/features/diary/presentation/bloc/diary_state.freezed.dart index 8a5aba44..6a06e2e4 100644 --- a/lib/features/diary/presentation/bloc/diary_state.freezed.dart +++ b/lib/features/diary/presentation/bloc/diary_state.freezed.dart @@ -23,12 +23,12 @@ mixin _$DiaryState { required TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -58,12 +58,12 @@ mixin _$DiaryState { TResult? Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -93,12 +93,12 @@ mixin _$DiaryState { TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -210,12 +210,12 @@ class _$DiaryStateImpl implements _DiaryState { required TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -248,12 +248,12 @@ class _$DiaryStateImpl implements _DiaryState { TResult? Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -286,12 +286,12 @@ class _$DiaryStateImpl implements _DiaryState { TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -405,12 +405,12 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { required TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -443,12 +443,12 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { TResult? Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -481,12 +481,12 @@ class _$DiaryStateLoadingImpl implements DiaryStateLoading { TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -566,12 +566,12 @@ abstract class _$$DiaryStateLoadedImplCopyWith<$Res> { $Res call( {DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -592,7 +592,7 @@ abstract class _$$DiaryStateLoadedImplCopyWith<$Res> { bool isAdded}); $DiaryModelCopyWith<$Res> get diary; - $MealCopyWith<$Res>? get currentMeal; + $MealCopyWith<$Res> get currentMeal; } /// @nodoc @@ -608,12 +608,12 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res> $Res call({ Object? diary = null, Object? diaryDate = freezed, - Object? autocompleteList = freezed, + Object? autocompleteList = null, Object? recommendedChartValues = null, Object? consumedChartValues = null, - Object? portions = freezed, - Object? photos = freezed, - Object? currentMeal = freezed, + Object? portions = null, + Object? photos = null, + Object? currentMeal = null, Object? portionController = freezed, Object? wakeupController = freezed, Object? retireController = freezed, @@ -642,10 +642,10 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res> ? _value.diaryDate : diaryDate // ignore: cast_nullable_to_non_nullable as String?, - autocompleteList: freezed == autocompleteList + autocompleteList: null == autocompleteList ? _value._autocompleteList : autocompleteList // ignore: cast_nullable_to_non_nullable - as List?, + as List, recommendedChartValues: null == recommendedChartValues ? _value._recommendedChartValues : recommendedChartValues // ignore: cast_nullable_to_non_nullable @@ -654,18 +654,18 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res> ? _value._consumedChartValues : consumedChartValues // ignore: cast_nullable_to_non_nullable as List, - portions: freezed == portions + portions: null == portions ? _value._portions : portions // ignore: cast_nullable_to_non_nullable - as List?, - photos: freezed == photos + as List, + photos: null == photos ? _value._photos : photos // ignore: cast_nullable_to_non_nullable - as List?, - currentMeal: freezed == currentMeal + as List, + currentMeal: null == currentMeal ? _value.currentMeal : currentMeal // ignore: cast_nullable_to_non_nullable - as Meal?, + as Meal, portionController: freezed == portionController ? _value.portionController : portionController // ignore: cast_nullable_to_non_nullable @@ -751,12 +751,8 @@ class __$$DiaryStateLoadedImplCopyWithImpl<$Res> @override @pragma('vm:prefer-inline') - $MealCopyWith<$Res>? get currentMeal { - if (_value.currentMeal == null) { - return null; - } - - return $MealCopyWith<$Res>(_value.currentMeal!, (value) { + $MealCopyWith<$Res> get currentMeal { + return $MealCopyWith<$Res>(_value.currentMeal, (value) { return _then(_value.copyWith(currentMeal: value)); }); } @@ -768,12 +764,12 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded { const _$DiaryStateLoadedImpl( {required this.diary, this.diaryDate, - final List? autocompleteList, + required final List autocompleteList, required final List recommendedChartValues, required final List consumedChartValues, - final List? portions, - final List? photos, - this.currentMeal, + required final List portions, + required final List photos, + required this.currentMeal, this.portionController, this.wakeupController, this.retireController, @@ -802,15 +798,13 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded { final DiaryModel diary; @override final String? diaryDate; - final List? _autocompleteList; + final List _autocompleteList; @override - List? get autocompleteList { - final value = _autocompleteList; - if (value == null) return null; + List get autocompleteList { if (_autocompleteList is EqualUnmodifiableListView) return _autocompleteList; // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); + return EqualUnmodifiableListView(_autocompleteList); } final List _recommendedChartValues; @@ -831,28 +825,24 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded { return EqualUnmodifiableListView(_consumedChartValues); } - final List? _portions; + final List _portions; @override - List? get portions { - final value = _portions; - if (value == null) return null; + List get portions { if (_portions is EqualUnmodifiableListView) return _portions; // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); + return EqualUnmodifiableListView(_portions); } - final List? _photos; + final List _photos; @override - List? get photos { - final value = _photos; - if (value == null) return null; + List get photos { if (_photos is EqualUnmodifiableListView) return _photos; // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); + return EqualUnmodifiableListView(_photos); } @override - final Meal? currentMeal; + final Meal currentMeal; @override final SelectionPopupModel? portionController; @override @@ -997,12 +987,12 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded { required TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -1061,12 +1051,12 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded { TResult? Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -1125,12 +1115,12 @@ class _$DiaryStateLoadedImpl implements DiaryStateLoaded { TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -1227,12 +1217,12 @@ abstract class DiaryStateLoaded implements DiaryState { const factory DiaryStateLoaded( {required final DiaryModel diary, final String? diaryDate, - final List? autocompleteList, + required final List autocompleteList, required final List recommendedChartValues, required final List consumedChartValues, - final List? portions, - final List? photos, - final Meal? currentMeal, + required final List portions, + required final List photos, + required final Meal currentMeal, final SelectionPopupModel? portionController, final TimeOfDay? wakeupController, final TimeOfDay? retireController, @@ -1254,12 +1244,12 @@ abstract class DiaryStateLoaded implements DiaryState { DiaryModel get diary; String? get diaryDate; - List? get autocompleteList; + List get autocompleteList; List get recommendedChartValues; List get consumedChartValues; - List? get portions; - List? get photos; - Meal? get currentMeal; + List get portions; + List get photos; + Meal get currentMeal; SelectionPopupModel? get portionController; TimeOfDay? get wakeupController; TimeOfDay? get retireController; @@ -1354,12 +1344,12 @@ class _$DiaryStateErrorImpl implements DiaryStateError { required TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -1392,12 +1382,12 @@ class _$DiaryStateErrorImpl implements DiaryStateError { TResult? Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, @@ -1430,12 +1420,12 @@ class _$DiaryStateErrorImpl implements DiaryStateError { TResult Function( DiaryModel diary, String? diaryDate, - List? autocompleteList, + List autocompleteList, List recommendedChartValues, List consumedChartValues, - List? portions, - List? photos, - Meal? currentMeal, + List portions, + List photos, + Meal currentMeal, SelectionPopupModel? portionController, TimeOfDay? wakeupController, TimeOfDay? retireController, diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index be3a7b44..af39f0b1 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -274,8 +274,7 @@ class DiaryScreen extends StatelessWidget { _buildMeal(BuildContext context, DiaryStateLoaded state) { final digitsOnly = FilteringTextInputFormatter.digitsOnly; List _options = - state.autocompleteList!.map((dynamic item) => item as String).toList(); - //print(_options); + state.autocompleteList.map((dynamic item) => item as String).toList(); FocusNode focusNodeName = FocusNode(); return Container( margin: EdgeInsets.symmetric(horizontal: 16.h), @@ -350,7 +349,6 @@ class DiaryScreen extends StatelessWidget { horizontal: 10.h, vertical: 9.v, ), - defaultValue: mealsToDropdown(diary.meals)[0], onChanged: changeMeal(context, state), ); }, @@ -448,7 +446,6 @@ class DiaryScreen extends StatelessWidget { SelectionPopupModel(title: "gr"), SelectionPopupModel(title: "pcs") ], - defaultValue: SelectionPopupModel(title: "gr"), onChanged: changePortion(context, state), ); }, @@ -461,7 +458,7 @@ class DiaryScreen extends StatelessWidget { SizedBox(height: 30.v), _buildAddProduct(context, state), SizedBox(height: 30.v), - ...state.portions! + ...state.portions .map((portion) => _buildProduct(context, portion)) .toList(), SizedBox(height: 30.v), @@ -673,12 +670,12 @@ class DiaryScreen extends StatelessWidget { } _buildCarousel(BuildContext context, DiaryStateLoaded state) { - if (state.currentMeal!.photos.isEmpty) { + if (state.currentMeal.photos.isEmpty) { return Text("Фото нет"); } else { return CarouselSlider( options: CarouselOptions(height: 340.0), - items: state.currentMeal!.photos.map((photo) { + items: state.currentMeal.photos.map((photo) { return _buildPhoto( context, photo); // Assuming photos are stored as strings }).toList(), @@ -1314,7 +1311,7 @@ List mealsToDropdown(List? meals) { return meals! .map((meal) => SelectionPopupModel( id: meal.id, - title: "Прием пищи ${meal.id}", + title: "Прием пищи ${meal.type}", isSelected: false, )) .toList();