diff --git a/lib/pages/image_viewer/image_viewer.dart b/lib/pages/image_viewer/image_viewer.dart index e99eb719b..2b2b315e0 100644 --- a/lib/pages/image_viewer/image_viewer.dart +++ b/lib/pages/image_viewer/image_viewer.dart @@ -45,22 +45,22 @@ class ImageViewerController extends State { late final List allEvents; - void prevImage() { - setState(() { - pageController.previousPage( - duration: FluffyThemes.animationDuration, - curve: FluffyThemes.animationCurve, - ); - }); + void prevImage() async { + await pageController.previousPage( + duration: FluffyThemes.animationDuration, + curve: FluffyThemes.animationCurve, + ); + if (!mounted) return; + setState(() {}); } - void nextImage() { - setState(() { - pageController.nextPage( - duration: FluffyThemes.animationDuration, - curve: FluffyThemes.animationCurve, - ); - }); + void nextImage() async { + await pageController.nextPage( + duration: FluffyThemes.animationDuration, + curve: FluffyThemes.animationCurve, + ); + if (!mounted) return; + setState(() {}); } int get _index => pageController.page?.toInt() ?? 0;