diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index bb9e530a..21ec0314 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -272,18 +272,18 @@ class _DiaryScreenState extends State { style: IconButton.styleFrom( backgroundColor: Colors.white, ), - onPressed: () { - setState(() { - if (currentSelectedPhotoIndex == photos.length - 1 && currentSelectedPhotoIndex != 0) { - currentSelectedPhotoIndex = photos.length - 2; - } - }); - diaryCubit.deletePhoto( + onPressed: () async { + await diaryCubit.deletePhoto( photo: photos[currentSelectedPhotoIndex], diaryId: diaryDay.id, mealId: diaryDay.meals[currentSelectedMealNumber - 1].id, date: _selectedDay.toString(), ); + setState(() { + if (currentSelectedPhotoIndex == photos.length - 1 && currentSelectedPhotoIndex != 0) { + currentSelectedPhotoIndex = photos.length - 2; + } + }); }, icon: Icon( Icons.close_rounded,