3

Unhandled Exception: Null check operator used on a null value

I am encountering an error when trying to compress videos. I am testing the app on an Iphone 12 pro.

I have tried using the following versions of the package:

  • 3.1.1
  • 3.1.0
  • 3.0.0

My system:

  • Computer: Macbook pro m1 13 (Monterey 12.4)
  • Phone for testing: Iphone 12 pro (15.5)
  • IDE: Visual Studio Code
  • Flutter version: 3.0.3

My code:

print("before compression");

final info = await VideoCompress.compressVideo(
  widget.filePath,
  quality: VideoQuality.MediumQuality,
  deleteOrigin: false,
  includeAudio: false,
);

print("after compression");

setState(() {
  compressedInfo = info!.path!; // Dart complains if I don't run a null-check here
  print("info set");
});

Error:

flutter: before compression
flutter: VideoCompress: You can try to subscribe to the
flutter:       compressProgress$ stream to know the compressing state.
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: Null check operator used on a null value
#0      new MediaInfo.fromJson (package:video_compress/src/media/media_info.dart:43:21)
#1      Compress.compressVideo (package:video_compress/src/video_compress/video_compressor.dart:154:24)
<asynchronous suspension>
#2      _VideoPageState.build.<anonymous closure> (package:apiir_bikefit/pages/record/video_page.dart:65:28)
<asynchronous suspension>

I first assumed that there was something wrong with the way I was handling the result of the compression (info) or that I had implemented the async await wrong. However, after trying different methods and researching online I can't seem to find the problem.

Additionally, it seems that print("after compression"); is never reached, indicating that there is something wrong with the compression function (though I'm not 100% sure).

Could this be a bug in the package, or am I just overlooking something?

Henrik
  • 61
  • 4
  • imageFormatGroup that you using to compress this is not supported in the ios – Ali Hassan Jul 15 '22 at 10:22
  • No, this does not cause the error. I tried setting the imageFormatGroup to yuv420, which is supported on iOS. This made the warning go away, but the original error still occurs. – Henrik Jul 15 '22 at 11:15
  • I'm having the same issue. I'm converting a video from the gallery (freshly recorded). The same function works if I record the video and then convert. – GoNinja Sep 18 '22 at 16:21

0 Answers0