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

Null check operator used on a null value #443

Open
gamestap99 opened this issue Jul 19, 2021 · 9 comments
Open

Null check operator used on a null value #443

gamestap99 opened this issue Jul 19, 2021 · 9 comments
Labels

Comments

@gamestap99
Copy link

I have a bug when user download app from store and chplay. The error detected by sentry package. I tried to check my code and i think error is started from your side
image

@gamestap99 gamestap99 added the bug Something isn't working label Jul 19, 2021
@gamestap99
Copy link
Author

this is device.
image

@deremakif
Copy link

I have a similar crash report. This is from Countly tools.

java.lang.Exception: Null check operator used on a null value

image

I think, you should fix this class:

class PhotoViewDefaultLoading extends StatelessWidget {
  const PhotoViewDefaultLoading({Key? key, this.event}) : super(key: key);

  final ImageChunkEvent? event;

  @override
  Widget build(BuildContext context) {
    final value = event == null || event?.expectedTotalBytes != null
        ? 0.0
        : event!.cumulativeBytesLoaded / event!.expectedTotalBytes!;
    return Center(
      child: Container(
        width: 20.0,
        height: 20.0,
        child: CircularProgressIndicator(value: value),
      ),
    );
  }
}

https://stackoverflow.com/a/67990442/10659482

image

@bounty1342
Copy link

There is also this one :

I/flutter (30573): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (30573): The following _CastError was thrown while finalizing the widget tree:
I/flutter (30573): Null check operator used on a null value
I/flutter (30573):
I/flutter (30573): When the exception was thrown, this was the stack:
I/flutter (30573): #0      IgnorableChangeNotifier.removeIgnorableListener
package:photo_view/…/utils/ignorable_change_notifier.dart:39
I/flutter (30573): #1      PhotoViewController.removeIgnorableListener
package:photo_view/…/controller/photo_view_controller.dart:173
I/flutter (30573): #2      PhotoViewControllerDelegate.dispose
package:photo_view/…/controller/photo_view_controller_delegate.dart:216
I/flutter (30573): #3      PhotoViewCoreState.dispose
package:photo_view/…/core/photo_view_core.dart:279
I/flutter (30573): #4      StatefulElement.unmount
package:flutter/…/widgets/framework.dart:4895
I/

@bounty1342
Copy link

And this one too :

I/flutter (30573): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (30573): The following _CastError was thrown building ImageWrapper(state: _ImageWrapperState#db9b3):
I/flutter (30573): Null check operator used on a null value
I/flutter (30573):
I/flutter (30573): The relevant error-causing widget was:
I/flutter (30573):   PhotoView
I/flutter (30573):
lib/…/picture/picture_widget.dart:529
I/flutter (30573):
I/flutter (30573): When the exception was thrown, this was the stack:
I/flutter (30573): #0      IgnorableChangeNotifier.addIgnorableListener
package:photo_view/…/utils/ignorable_change_notifier.dart:34
I/flutter (30573): #1      PhotoViewController.addIgnorableListener
package:photo_view/…/controller/photo_view_controller.dart:168
I/flutter (30573): #2      PhotoViewControllerDelegate.initDelegate
package:photo_view/…/controller/photo_view_controller_delegate.dart:37
I/flutter (30573): #3      PhotoViewCoreState.initState
package:photo_view/…/core/photo_view_core.dart:261
I/flutter (30573): #4      StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4805
I/flutter (30573): #5      ComponentElement.mount
package:flutter/…/widgets/framework.dart:4638

@helenkravchenko
Copy link

Hi, I am using photo_view: ^0.13.0 from 5 Oct and the issue that @deremakif described is still present. Could you please fix it)

@helenkravchenko
Copy link

Thank you!

@bounty1342
Copy link

@renancaraujo, the issue in my previous comment happen with routing, or if you dispose the controller and immediately create a new one to get a new initPosition for exemple.

There is a very simple fix, just protect the nullity with ? instead of enforcing int with ! in the dispose method.
Anyway, enforcing '!' on a method call is a bad pattern and should be avoid 😈 (Otherwise, it should not be nullable but late)

  void removeIgnorableListener(listener) {
    assert(_debugAssertNotDisposed());
    _ignorableListeners!.remove(listener);
  }
  void removeIgnorableListener(listener) {
    assert(_debugAssertNotDisposed());
    _ignorableListeners?.remove(listener);
  }

Let me know if you want a PR for it.

Regards

@eliabieri
Copy link

eliabieri commented Mar 24, 2022

Any updates on this?
I'd love to see a PR for this

@renancaraujo
Copy link
Member

Is this still hapening on 0.14.0?

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

No branches or pull requests

6 participants