Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter: ERROR:Null check operator used on a null value #7

Closed
Noor-Mahammad opened this issue May 24, 2023 · 2 comments
Closed

flutter: ERROR:Null check operator used on a null value #7

Noor-Mahammad opened this issue May 24, 2023 · 2 comments

Comments

@Noor-Mahammad
Copy link

When I'm trying to scan a QR in live it showing me like this ERROR:Null check operator used on a null value

@philseeley
Copy link
Contributor

Hi Rafael,

A bit more info...

I only get this on iOS and not Android:

flutter: ERROR(decodePlanes):Null check operator used on a null value

I've run in debug and the error is happening in "transformToLuminanceSource" in "decoder/global_functions.dart".

On Android (Android 13 (API 33)): e.bytesPerPixel = 0
On iOS (iOS 16.6 20G75): e.bytesPerPixel = null

The null exception is thrown during the "map" to get the "total":

  final total = planes
      .map<double>((p) => p.bytesPerPixel!.toDouble())
      .reduce((value, element) => value + 1 / element)
      .toInt();

In the definition of "Plane" in "camera_image.dart" it says:

  /// The distance between adjacent pixel samples on Android, in bytes.
  ///
  /// Will be `null` on iOS.
  final int? bytesPerPixel;

So I've put in a null test and a default of "1" in "transformToLuminanceSource" and that works for me on iOS.

I'll submit a pull request for you to check.

Cheers
Phil

@RafaelBarbosatec
Copy link
Owner

Wow. Thanks so much @philseeley !
I'm wait anxious for your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants