Flutter Image Compress 给出的结果为空

Flutter Image Compress giving result as null

压缩结果为空

File compressed = await FlutterImageCompress.compressAndGetFile(
        img.path,
        img.path.split('/').last,
        quality: 80,
      );

      ref = firebase_storage.FirebaseStorage.instance
          .ref()
          .child('postimages/${Path.basename(img.path)}');
      await ref.putFile(compressed);

这就是我遇到的错误

E/flutter (12851): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception:
NoSuchMethodError: The getter 'absolute' was called on null.
E/flutter (12851): Receiver: null
E/flutter (12851): Tried calling: absolute
E/flutter (12851): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
E/flutter (12851): #1 Reference.putFile
package:firebase_storage/src/reference.dart:126
E/flutter (12851): #2 _AddImageState.uploadFile
package:softclaw/…/addpost/addimage.dart:228
E/flutter (12851):
E/flutter (12851):

这会很好用

final imageUri = Uri.parse(img.path);
      final String outputUri = imageUri.resolve('./output.webp').toString();
      print(imageUri.toFilePath());

      File compressed = await FlutterImageCompress.compressAndGetFile(
          img.path, outputUri,
          quality: 80, format: CompressFormat.webp);
      print(img.path);
      print(outputUri);

      ref = firebase_storage.FirebaseStorage.instance
          .ref()
          .child('postimages/${Path.basename(img.path)}');
      await ref.putFile(compressed);
      _imageName.add(await ref.getDownloadURL());
    }