Преглед на файлове

Merge pull request #805 from ente-io/fix_null_safety_suggestion

Fix bad null safety suggetion
Neeraj Gupta преди 2 години
родител
ревизия
6ced975b8b
променени са 1 файла, в които са добавени 13 реда и са изтрити 13 реда
  1. 13 13
      lib/ui/viewer/file/zoomable_image.dart

+ 13 - 13
lib/ui/viewer/file/zoomable_image.dart

@@ -16,7 +16,7 @@ import 'package:photos/utils/file_util.dart';
 import 'package:photos/utils/thumbnail_util.dart';
 
 class ZoomableImage extends StatefulWidget {
-  final File? photo;
+  final File photo;
   final Function(bool)? shouldDisableScroll;
   final String? tagPrefix;
   final Decoration? backgroundDecoration;
@@ -36,7 +36,7 @@ class ZoomableImage extends StatefulWidget {
 class _ZoomableImageState extends State<ZoomableImage>
     with SingleTickerProviderStateMixin {
   final Logger _logger = Logger("ZoomableImage");
-  File? _photo;
+  late File _photo;
   ImageProvider? _imageProvider;
   bool _loadedSmallThumbnail = false;
   bool _loadingLargeThumbnail = false;
@@ -63,7 +63,7 @@ class _ZoomableImageState extends State<ZoomableImage>
 
   @override
   Widget build(BuildContext context) {
-    if (_photo!.isRemoteFile) {
+    if (_photo.isRemoteFile) {
       _loadNetworkImage();
     } else {
       _loadLocalImage(context);
@@ -79,7 +79,7 @@ class _ZoomableImageState extends State<ZoomableImage>
           minScale: PhotoViewComputedScale.contained,
           gaplessPlayback: true,
           heroAttributes: PhotoViewHeroAttributes(
-            tag: widget.tagPrefix! + _photo!.tag,
+            tag: widget.tagPrefix! + _photo.tag,
           ),
           backgroundDecoration: widget.backgroundDecoration as BoxDecoration?,
         ),
@@ -107,7 +107,7 @@ class _ZoomableImageState extends State<ZoomableImage>
         _imageProvider = Image.memory(cachedThumbnail).image;
         _loadedSmallThumbnail = true;
       } else {
-        getThumbnailFromServer(_photo!).then((file) {
+        getThumbnailFromServer(_photo).then((file) {
           final imageProvider = Image.memory(file).image;
           if (mounted) {
             precacheImage(imageProvider, context).then((value) {
@@ -126,7 +126,7 @@ class _ZoomableImageState extends State<ZoomableImage>
       }
     }
     if (!_loadedFinalImage) {
-      getFileFromServer(_photo!).then((file) {
+      getFileFromServer(_photo).then((file) {
         _onFinalImageLoaded(
           Image.file(
             file!,
@@ -153,7 +153,7 @@ class _ZoomableImageState extends State<ZoomableImage>
         !_loadedLargeThumbnail &&
         !_loadedFinalImage) {
       _loadingLargeThumbnail = true;
-      getThumbnailFromLocal(_photo!, size: thumbnailLargeSize, quality: 100)
+      getThumbnailFromLocal(_photo, size: thumbnailLargeSize, quality: 100)
           .then((cachedThumbnail) {
         if (cachedThumbnail != null) {
           _onLargeThumbnailLoaded(Image.memory(cachedThumbnail).image, context);
@@ -164,7 +164,7 @@ class _ZoomableImageState extends State<ZoomableImage>
     if (!_loadingFinalImage && !_loadedFinalImage) {
       _loadingFinalImage = true;
       getFile(
-        _photo!,
+        _photo,
         isOrigin: Platform.isIOS &&
             _isGIF(), // since on iOS GIFs playback only when origin-files are loaded
       ).then((file) {
@@ -172,12 +172,12 @@ class _ZoomableImageState extends State<ZoomableImage>
           _onFinalImageLoaded(Image.file(file).image);
         } else {
           _logger.info("File was deleted " + _photo.toString());
-          if (_photo!.uploadedFileID != null) {
-            _photo!.localID = null;
-            FilesDB.instance.update(_photo!);
+          if (_photo.uploadedFileID != null) {
+            _photo.localID = null;
+            FilesDB.instance.update(_photo);
             _loadNetworkImage();
           } else {
-            FilesDB.instance.deleteLocalFile(_photo!);
+            FilesDB.instance.deleteLocalFile(_photo);
             Bus.instance.fire(
               LocalPhotosUpdatedEvent(
                 [_photo],
@@ -220,5 +220,5 @@ class _ZoomableImageState extends State<ZoomableImage>
     }
   }
 
-  bool _isGIF() => _photo!.displayName.toLowerCase().endsWith(".gif");
+  bool _isGIF() => _photo.displayName.toLowerCase().endsWith(".gif");
 }