Browse Source

Mark `_file` as a late initialized variable to fix compilation errors

vishnukvmd 2 năm trước cách đây
mục cha
commit
21c7f36f88
1 tập tin đã thay đổi với 5 bổ sung5 xóa
  1. 5 5
      lib/ui/viewer/file/zoomable_live_image.dart

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

@@ -32,7 +32,7 @@ class ZoomableLiveImage extends StatefulWidget {
 class _ZoomableLiveImageState extends State<ZoomableLiveImage>
     with SingleTickerProviderStateMixin {
   final Logger _logger = Logger("ZoomableLiveImage");
-  File? _file;
+  late File _file;
   bool _showVideo = false;
   bool _isLoadingVideoPlayer = false;
 
@@ -118,14 +118,14 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
       return;
     }
     _isLoadingVideoPlayer = true;
-    if (_file!.isRemoteFile && !(await isFileCached(_file!, liveVideo: true))) {
+    if (_file.isRemoteFile && !(await isFileCached(_file, liveVideo: true))) {
       showShortToast(context, "Downloading...");
     }
 
     io.File? videoFile = await getFile(widget.file, liveVideo: true)
         .timeout(const Duration(seconds: 15))
         .onError((dynamic e, s) {
-      _logger.info("getFile failed ${_file!.tag}", e);
+      _logger.info("getFile failed ${_file.tag}", e);
       return null;
     });
 
@@ -133,11 +133,11 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
     // getFile with liveVideo as true can fail for file with localID when
     // the live photo was downloaded from remote.
     if ((videoFile == null || !videoFile.existsSync()) &&
-        _file!.uploadedFileID != null) {
+        _file.uploadedFileID != null) {
       videoFile = await getFileFromServer(widget.file, liveVideo: true)
           .timeout(const Duration(seconds: 15))
           .onError((dynamic e, s) {
-        _logger.info("getRemoteFile failed ${_file!.tag}", e);
+        _logger.info("getRemoteFile failed ${_file.tag}", e);
         return null;
       });
     }