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
800 stars 275 forks source link

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

Closed sentry-io[bot] closed 2 years ago

sentry-io[bot] commented 2 years ago

Sentry Issue: SMOOTHIE-S0

_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
  File "html_table.dart", line 493, in _TableRenderObject._performLayoutLayouter
  File "html_table.dart", line 493, in _TableRenderObject._performLayoutLayouter
...
(203 additional frame(s) were not displayed)
monsieurtanuki commented 2 years ago

Suggestion in SmoothProductCarousel(I cannot test the camera on my emulator, I cannot test the https API calls on my old smartphone) (but I've checked that at init, with an empty carousel, the error message is not there anymore):

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    final ContinuousScanModel model = context.watch<ContinuousScanModel>();
    setState(() {
      barcodes = model.getBarcodes();
    });
    if (barcodes.isEmpty) { // what would animation mean with an empty list?
      return;
    }
    _controller.animateToPage(barcodes.length - 1 + _searchCardAdjustment);
  }
M123-dev commented 2 years ago

Fixed