Przeglądaj źródła

[Unrelated] Ensure that the widget is mounted before using BuildContext

vishnukvmd 2 lat temu
rodzic
commit
56339cea5d
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      lib/ui/viewer/file/zoomable_live_image.dart

+ 1 - 1
lib/ui/viewer/file/zoomable_live_image.dart

@@ -166,7 +166,7 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
   void _showLivePhotoToast() async {
   void _showLivePhotoToast() async {
     var preferences = await SharedPreferences.getInstance();
     var preferences = await SharedPreferences.getInstance();
     int promptTillNow = preferences.getInt(kLivePhotoToastCounterKey) ?? 0;
     int promptTillNow = preferences.getInt(kLivePhotoToastCounterKey) ?? 0;
-    if (promptTillNow < kMaxLivePhotoToastCount) {
+    if (promptTillNow < kMaxLivePhotoToastCount && mounted) {
       showToast(context, "Press and hold to play video");
       showToast(context, "Press and hold to play video");
       preferences.setInt(kLivePhotoToastCounterKey, promptTillNow + 1);
       preferences.setInt(kLivePhotoToastCounterKey, promptTillNow + 1);
     }
     }