From 39b43e88ec67ac3ac65f4691b72e6dadfe178c30 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Fri, 1 Nov 2024 12:14:30 +0300 Subject: [PATCH] feat(diary): fix gallery delete image --- .../diary/presentation/pages/diary_screen.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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,