From 2e23148532d6bfd5d76ff38c2f15ea35f2b40c6c Mon Sep 17 00:00:00 2001 From: krawieck Date: Sun, 13 Sep 2020 16:48:40 +0200 Subject: [PATCH] move ui showing/hiding logic to `useEffect` --- lib/pages/media_view.dart | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/pages/media_view.dart b/lib/pages/media_view.dart index aae1f38..e387d6a 100644 --- a/lib/pages/media_view.dart +++ b/lib/pages/media_view.dart @@ -17,19 +17,20 @@ class MediaViewPage extends HookWidget { final showButtons = useState(true); final isZoomedOut = useState(true); - useEffect(() => () => SystemChrome.setEnabledSystemUIOverlays([ + useEffect(() { + if (showButtons.value) { + SystemChrome.setEnabledSystemUIOverlays([ SystemUiOverlay.bottom, SystemUiOverlay.top, - ])); - - if (showButtons.value) { - SystemChrome.setEnabledSystemUIOverlays([ - SystemUiOverlay.bottom, - SystemUiOverlay.top, - ]); - } else { - SystemChrome.setEnabledSystemUIOverlays([]); - } + ]); + } else { + SystemChrome.setEnabledSystemUIOverlays([]); + } + return () => SystemChrome.setEnabledSystemUIOverlays([ + SystemUiOverlay.bottom, + SystemUiOverlay.top, + ]); + }); share() { showModalBottomSheet(