openfoodfacts / smooth-app

🤳🥫 The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo
Apache License 2.0
853 stars 282 forks source link

_CastError: Null check operator used on a null value #686

Closed sentry-io[bot] closed 2 years ago

sentry-io[bot] commented 2 years ago

Sentry Issue: SMOOTHIE-ANDROID-JQ

What

_CastError: Null check operator used on a null value
  File "carousel_controller.dart", line 106, in CarouselControllerImpl.animateToPage
  File "smooth_product_carousel.dart", line 40, in _SmoothProductCarouselState.didChangeDependencies
...
(158 additional frame(s) were not displayed)

Part of

monsieurtanuki commented 2 years ago

For what it's worth, there's a potential fix for the crash in SmoothProductCarousel:

@override
void didChangeDependencies() {
  super.didChangeDependencies();
  final ContinuousScanModel model = context.watch<ContinuousScanModel>();
  setState(() {
    barcodes = model.getBarcodes();
  });
  if (_controller.ready) { // that's the fix
    _controller.animateToPage(barcodes.length - 1 + _searchCardAdjustment);
  }
}

With that, no crash. Will the animation take place eventually: I don't know. Unfortunately I cannot really test that because 1. my smartphone is too old to use https queries (at least with smoothie) and 2. with the emulators I haven't tested how to scan (and anyway my computer is already slow enough).