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

list_wheel_scroll_view.dart throws Null check operator used on a null value error while loading images #60578

Closed
Faiyyaz opened this issue Jun 30, 2020 · 26 comments
Labels
c: crash Stack traces logged to the console f: scrolling Viewports, list views, slivers, etc. found in release: 2.0 Found to occur in 2.0 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list r: fixed Issue is closed as already fixed in a newer version

Comments

@Faiyyaz
Copy link

Faiyyaz commented Jun 30, 2020

════════ Exception caught by image resource service ════════════════════════════════════════════════
The following NoSuchMethodError was thrown while resolving an image:
The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()

When the exception was thrown, this was the stack: 
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      double.> (dart:core-patch/double.dart:96:31)
#2      max (dart:math-patch/math_patch.dart:45:9)
#3      _clipOffsetToScrollableRange (package:flutter/src/widgets/list_wheel_scroll_view.dart:362:19)
#4      _getItemFromOffset (package:flutter/src/widgets/list_wheel_scroll_view.dart:354:11)
...
Image provider: ScrollAwareImageProvider<dynamic>()
Image configuration: ImageConfiguration(bundle: PlatformAssetBundle#fe6d4(), devicePixelRatio: 3.0, locale: en_US, textDirection: TextDirection.ltr, size: Size(30.0, 20.0), platform: iOS)
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#fe6d4(), name: "packages/country_pickers/assets/af.png", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by image resource service ════════════════════════════════════════════════
The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by image resource service ════════════════════════════════════════════════
The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()
════════════════════════════════════════════════════════════════════════════════════════════════════
Application finished.

[✓] Flutter (Channel stable, v1.17.4, on Mac OS X 10.15.5 19F101, locale en-GB)
    • Flutter version 1.17.4 at /users/faiyyazkhatri/StudioProjects/flutter
    • Framework revision 1ad9baa8b9 (12 days ago), 2020-06-17 14:41:16 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /users/faiyyazkhatri/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = /users/faiyyazkhatri/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.1

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 47.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • CFC77C34-A397-4FC3-802E-115F3A7224FA • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)

• No issues found!
@darshankawar
Copy link
Member

Hi @Faiyyaz,
Can you please provide a minimal complete reproducible code sample.
Thank you.

@darshankawar darshankawar added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Jun 30, 2020
@Faiyyaz
Copy link
Author

Faiyyaz commented Jun 30, 2020

This is the class of a pub named country picker https://pub.dev/packages/country_pickers and this class internally uses the list_wheel_scroll_view.dart which returns the error

import 'package:country_pickers/countries.dart';
import 'package:country_pickers/country.dart';
import 'package:country_pickers/utils/typedefs.dart';
import 'package:country_pickers/utils/utils.dart';
import 'package:flutter/cupertino.dart';
import 'dart:core';

const double defaultPickerSheetHeight = 216.0;
const double defaultPickerItemHeight = 32.0;

/// Color of picker background
const Color _kDefaultBackground = Color(0xFFD2D4DB);

// Eyeballed values comparing with a native picker.
// Values closer to PI produces denser flatter lists.
const double _kDefaultDiameterRatio = 1.35;

///Provides a customizable [CupertinoPicker] which displays all countries
/// in cupertino style
class CountryPickerCupertino extends StatefulWidget {
  /// Callback that is called with selected Country
  final ValueChanged<Country> onValuePicked;

  /// Filters the available country list
  final ItemFilter itemFilter;

  /// [Comparator] to be used in sort of country list
  final Comparator<Country> sortComparator;

  /// List of countries that are placed on top
  final List<Country> priorityList;

  ///Callback that is called with selected item of type Country which returns a
  ///Widget to build list view item inside dialog
  final ItemBuilder itemBuilder;

  ///The [itemExtent] of [CupertinoPicker]
  /// The uniform height of all children.
  ///
  /// All children will be given the [BoxConstraints] to match this exact
  /// height. Must not be null and must be positive.
  final double pickerItemHeight;

  ///The height of the picker
  final double pickerSheetHeight;

  ///The TextStyle that is applied to Text widgets inside item
  final TextStyle textStyle;

  /// Relative ratio between this picker's height and the simulated cylinder's diameter.
  ///
  /// Smaller values creates more pronounced curvatures in the scrollable wheel.
  ///
  /// For more details, see [ListWheelScrollView.diameterRatio].
  ///
  /// Must not be null and defaults to `1.1` to visually mimic iOS.
  final double diameterRatio;

  /// Background color behind the children.
  ///
  /// Defaults to a gray color in the iOS color palette.
  ///
  /// This can be set to null to disable the background painting entirely; this
  /// is mildly more efficient than using [Colors.transparent].
  final Color backgroundColor;

  /// {@macro flutter.rendering.wheelList.offAxisFraction}
  final double offAxisFraction;

  /// {@macro flutter.rendering.wheelList.useMagnifier}
  final bool useMagnifier;

  /// {@macro flutter.rendering.wheelList.magnification}
  final double magnification;

  final Country initialCountry;

  /// A [FixedExtentScrollController] to read and control the current item.
  ///
  /// If null, an implicit one will be created internally.
  final FixedExtentScrollController scrollController;

  const CountryPickerCupertino({
    Key key,
    this.onValuePicked,
    this.itemBuilder,
    this.itemFilter,
    this.sortComparator,
    this.priorityList,
    this.pickerItemHeight = defaultPickerItemHeight,
    this.pickerSheetHeight = defaultPickerSheetHeight,
    this.textStyle,
    this.diameterRatio = _kDefaultDiameterRatio,
    this.backgroundColor = _kDefaultBackground,
    this.offAxisFraction = 0.0,
    this.useMagnifier = false,
    this.magnification = 1.0,
    this.scrollController,
    this.initialCountry,
  }) : super(key: key);

  @override
  _CupertinoCountryPickerState createState() => _CupertinoCountryPickerState();
}

class _CupertinoCountryPickerState extends State<CountryPickerCupertino> {
  List<Country> _countries;
  FixedExtentScrollController _scrollController;

  @override
  void initState() {
    super.initState();

    _countries =
        countryList.where(widget.itemFilter ?? acceptAllCountries).toList();

    if (widget.sortComparator != null) {
      _countries.sort(widget.sortComparator);
    }

    if (widget.priorityList != null) {
      widget.priorityList.forEach((Country country) =>
          _countries.removeWhere((Country c) => country.isoCode == c.isoCode));
      _countries.insertAll(0, widget.priorityList);
    }

    _scrollController = this.widget.scrollController;

    if ((_scrollController == null) && (this.widget.initialCountry != null)) {
      var countyInList = _countries
          .where((c) => c.phoneCode == this.widget.initialCountry.phoneCode)
          .first;
      _scrollController = FixedExtentScrollController(
          initialItem: _countries.indexOf(countyInList));
    }
  }

  @override
  Widget build(BuildContext context) {
    return _buildBottomPicker(_buildPicker(), context);
  }

  Widget _buildBottomPicker(Widget picker, BuildContext context) {
    var mediaQueryData = MediaQuery.of(context);

    return Container(
      padding: EdgeInsets.only(bottom: mediaQueryData.padding.bottom),
      height: widget.pickerSheetHeight + mediaQueryData.padding.bottom,
      child: DefaultTextStyle(
        style: widget.textStyle ??
            const TextStyle(
              color: CupertinoColors.black,
              fontSize: 16.0,
            ),
        child: GestureDetector(
          // Blocks taps from propagating to the modal sheet and popping.
          onTap: () {},
          child: picker,
        ),
      ),
    );
  }

  Widget _buildPicker() {
    return CupertinoPicker(
      scrollController: _scrollController,
      itemExtent: widget.pickerItemHeight,
      diameterRatio: widget.diameterRatio,
      backgroundColor: widget.backgroundColor,
      offAxisFraction: widget.offAxisFraction,
      useMagnifier: widget.useMagnifier,
      magnification: widget.magnification,
      children: _countries
          .map<Widget>((Country country) => widget.itemBuilder != null
              ? widget.itemBuilder(country)
              : _buildDefaultItem(country))
          .toList(),
      onSelectedItemChanged: (int index) {
        widget.onValuePicked(_countries[index]);
      },
    );
  }

  _buildDefaultItem(Country country) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 8.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          CountryPickerUtils.getDefaultFlagImage(country),
          SizedBox(width: 8.0),
          Flexible(child: Text(country.name))
        ],
      ),
    );
  }
}

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 30, 2020
@darshankawar
Copy link
Member

Hi @Faiyyaz,
From what I can see, the issue is related to 3rd party plugin (country_pickers) rather than to Flutter itself. I see that you've already open similar issue against that plugin's repo. I'd suggest you follow-up with owner of that plugin.
Closing, as this isn’t an issue with Flutter itself.
If you disagree, please write in the comments,
providing your flutter doctor -v, your flutter run -v, your pubspec.yaml
a minimal reproducible code sample that does not use 3rd party plugins,
and I will reopen it.
Thank you

@darshankawar darshankawar removed the in triage Presently being triaged by the triage team label Jun 30, 2020
@didierganthier
Copy link

Hi @Faiyyaz,
From what I can see, the issue is related to 3rd party plugin (country_pickers) rather than to Flutter itself. I see that you've already open similar issue against that plugin's repo. I'd suggest you follow-up with owner of that plugin.
Closing, as this isn’t an issue with Flutter itself.
If you disagree, please write in the comments,
providing your flutter doctor -v, your flutter run -v, your pubspec.yaml
a minimal reproducible code sample that does not use 3rd party plugins,
and I will reopen it.
Thank you

And don't use this plugin but I'm facing this same issue so I doubt it's related

@0xPixelfrost
Copy link

0xPixelfrost commented Sep 30, 2020

Same here. The cause for this bug is, like mentioned above, the list_wheel_scroll_view.

Following code causes the crash. minScrollExtend and maxScrollExtend are both null:
double _clipOffsetToScrollableRange( double offset, double minScrollExtent, double maxScrollExtent, ) { return math.min(math.max(offset, minScrollExtent), maxScrollExtent); }

I could temporary fix this by checking the line for null values like:
double _clipOffsetToScrollableRange( double offset, double minScrollExtent, double maxScrollExtent, ) { return math.min(math.max(offset, minScrollExtent ?? 0.0), maxScrollExtent ?? 0.0); }

I could not check the beta and dev channels due to other bugs in the framework.

[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.7 19H2, locale en-US)
    • Flutter version 1.20.4 at /Users/luckym/dev/flutter/sdk
    • Framework revision fba99f6cf9 (2 weeks ago), 2020-09-14 15:32:52 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2

Pubspec:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  async: ^2.4.1
  kt_dart: ^0.7.0+1
  freezed_annotation: ^0.12.0

  provider: ^4.3.2+2
  get_it: ^5.0.1

  logger: ^0.9.2
  flutter_svg: ^0.19.0
  transparent_image: ^1.0.0
  url_launcher: ^5.5.2
  cached_network_image: ^2.3.2+1
  cupertino_icons: ^0.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^1.10.1
  freezed: ^0.12.0
  json_serializable: ^3.3.0
  pedantic: ^1.9.0
  mockito: ^4.1.1

@bounty1342
Copy link

bounty1342 commented Feb 4, 2021

@darshankawar, this is not related to any plugin but Cupertino Picker :

flutter: NoSuchMethodError: The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()
flutter: #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      double.> (dart:core-patch/double.dart:94:31)
#2      max (dart:math-patch/math_patch.dart:43:9)
#3      _clipOffsetToScrollableRange
package:flutter/…/widgets/list_wheel_scroll_view.dart:364
#4      _getItemFromOffset
package:flutter/…/widgets/list_wheel_scroll_view.dart:356
#5      _FixedExtentScrollPosition.itemIndex
package:flutter/…/widgets/list_wheel_scroll_view.dart:399
#6      _FixedExtentScrollPosition.copyWith
package:flutter/…/widgets/list_wheel_scroll_view.dart:422
#7      ScrollPosition.recommendDeferredLoading
package:flutter/…/widgets/scroll_position.dart:874
#8      Scrollable.recommendDeferredLoadingForContext
package:flutter/…/widgets/scrollable.dart:298
#9      ScrollAwareImageProvider.resolveStreamForKey
package:flutter/…/widgets/scroll_aware_image_provider.dart:100
#10     ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting<…>
flutter: NoSuchMethodError: The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()

Please reopen !

@darshankawar
Copy link
Member

darshankawar commented Feb 5, 2021

@bounty1342
This is an old and closed issue. I suggest you to open a new issue and provide flutter doctor -v and minimal reproducible code sample.

@bounty1342

This comment has been minimized.

@darshankawar
Copy link
Member

@bounty1342
It wasn't a bot response, sorry, and if you read from my response, I requested latest flutter doctor -v and a minimal reproducible code sample that shows the issue.

@bounty1342
Copy link

bounty1342 commented Feb 18, 2021

flutter doctor -v

[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.1 20D74 darwin-x64, locale en-GB)
    • Flutter version 1.22.6 at /Users/bounty1342/Documents/work/app/flutter
    • Framework revision 9b2d32b605 (4 weeks ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/bounty1342/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.10.1

[!] Android Studio
    • Android Studio at /Applications/Android Studio 4.2 Preview.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin installed
    • Dart plugin version 201.9317
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0

[✓] Connected device (2 available)
    • sdk google atv x86 (mobile) • emulator-5554                        • android-x86 • Android 10 (API 29) (emulator)
    • iPhone 12 Pro Max (mobile)  • 7FC20A84-7B08-43AA-BF0C-E183104B503B • ios         • com.apple.CoreSimulator.SimRuntime.iOS-14-2 (simulator)

! Doctor found issues in 1 category.

Issue found

════════ Exception caught by image resource service ════════════════════════════
The following NoSuchMethodError was thrown while resolving an image:
The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()

When the exception was thrown, this was the stack
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      double.> (dart:core-patch/double.dart:94:31)
#2      max (dart:math-patch/math_patch.dart:43:9)
#3      _clipOffsetToScrollableRange
package:flutter/…/widgets/list_wheel_scroll_view.dart:364
#4      _getItemFromOffset
package:flutter/…/widgets/list_wheel_scroll_view.dart:356
...
Image provider: ScrollAwareImageProvider<dynamic>()
Image configuration: ImageConfiguration(bundle: PlatformAssetBundle#94b6e(), devicePixelRatio: 3.0, locale: en_US, textDirection: TextDirection.ltr, platform: iOS)
Image key: NetworkImage("https://e7.pngegg.com/pngimages/595/79/png-clipart-dart-programming-language-flutter-object-oriented-programming-flutter-logo-class-fauna-thumbnail.png", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by image resource service ════════════════════════════
The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()
════════════════════════════════════════════════════════════════════════════════

minimal reproducible code sample

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

const url =
    "https://e7.pngegg.com/pngimages/595/79/png-clipart-dart-programming-language-flutter-object-oriented-programming-flutter-logo-class-fauna-thumbnail.png";

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  FixedExtentScrollController _controller;
  int _currentIndex;

  @override
  void initState() {
    super.initState();
    _currentIndex = 0;
    _controller = FixedExtentScrollController(
      initialItem: _currentIndex,
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("ScrollWheel"),
      ),
      body: SingleChildScrollView(
          child: Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        child: CupertinoPicker.builder(
          scrollController: _controller,
          offAxisFraction: 0.0,
          itemExtent: 80,
          childCount: 20,
          useMagnifier: true,
          magnification: 1.1,
          diameterRatio: 0.5,
          backgroundColor: Colors.red,
          onSelectedItemChanged: (value) {
            setState(() {
              print(value);
            });
          },
          itemBuilder: (context, index) =>
              SizedBox(height: 80, child: Center(child: Image.network(url))),
        ),
      )),
    );
  }
}
Screenshot of issue : Expected screenshot (with #60578 (comment)):

@darshankawar : Sorry, really thought it was. I did everything you asked for, so please reopen and take care of it.

@darshankawar
Copy link
Member

@bounty1342
Thanks for the details. I was able to replicate the issue on latest stable, but wondering how this is different from #61228, considering both throws same error upon image loading.

@bounty1342
Copy link

This one is anterior and have a valid correction proposition.

True fact, I don't care if this is this one or the other one, but this is up for more than 7 months now... where issue can be corrected by adding 2 null checks.

@darshankawar
Copy link
Member

@bounty1342
Tried the code sample on latest stable (2.0.6) using null safety version and see below error:

Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running Xcode build...
Xcode build done.                                           17.9s
Debug service listening on ws://127.0.0.1:50391/sMw5cbbPQSE=/ws
Syncing files to device iPhone 12 Pro Max...

======== Exception caught by image resource service ================================================
The following _CastError was thrown while resolving an image:
Null check operator used on a null value

When the exception was thrown, this was the stack: 
#0      ScrollPosition.minScrollExtent (package:flutter/src/widgets/scroll_position.dart:136:49)
#1      _FixedExtentScrollPosition.itemIndex (package:flutter/src/widgets/list_wheel_scroll_view.dart:398:24)
#2      _FixedExtentScrollPosition.copyWith (package:flutter/src/widgets/list_wheel_scroll_view.dart:418:36)
#3      ScrollPosition.recommendDeferredLoading (package:flutter/src/widgets/scroll_position.dart:915:7)
#4      Scrollable.recommendDeferredLoadingForContext (package:flutter/src/widgets/scrollable.dart:295:28)
...
Image provider: ScrollAwareImageProvider<Object>()
Image configuration: ImageConfiguration(bundle: PlatformAssetBundle#58dcc(), devicePixelRatio: 3.0, locale: en_US, textDirection: TextDirection.ltr, platform: iOS)
Image key: NetworkImage("https://e7.pngegg.com/pngimages/595/79/png-clipart-dart-programming-language-flutter-object-oriented-programming-flutter-logo-class-fauna-thumbnail.png", scale: 1.0)
====================================================================================================

======== Exception caught by image resource service ================================================
Null check operator used on a null value
====================================================================================================

======== Exception caught by image resource service ================================================
Null check operator used on a null value
====================================================================================================

======== Exception caught by image resource service ================================================
Null check operator used on a null value
====================================================================================================

======== Exception caught by image resource service ================================================
Null check operator used on a null value
====================================================================================================

======== Exception caught by image resource service ================================================
Null check operator used on a null value
====================================================================================================

======== Exception caught by image resource service ================================================
Null check operator used on a null value
====================================================================================================

======== Exception caught by image resource service ================================================
Null check operator used on a null value
====================================================================================================

======== Exception caught by image resource service ================================================
Null check operator used on a null value
====================================================================================================
Application finished.

@bounty1342

This comment has been minimized.

@darshankawar
Copy link
Member

@bounty1342
Not sure you properly read my comment or not, but I said, I tried the code sample you provided on latest stable (2.0.6) which now gives a different error than you had reported earlier irrespective of null safety or not. Developers are expected to upgrade to latest available version and I tried doing the same to see if it fixed the issue or not and commented here based on my observation.

@bounty1342
Copy link

Alright, but it kind of make sens that without correction it won't work.

The propose solution that fixed the issue 2 month ago was => double _clipOffsetToScrollableRange( double offset, double minScrollExtent, double maxScrollExtent, ) { return math.min(math.max(offset, minScrollExtent ?? 0.0), maxScrollExtent ?? 0.0); }

Now the error change with null-safety to Null check operator used on a null value, because those minScrollExtent and maxScrollExtent getter are declare non-nullable but the variable actually is :

  @override
  double get minScrollExtent => _minScrollExtent!;
  double? _minScrollExtent;

  @override
  double get maxScrollExtent => _maxScrollExtent!;
  double? _maxScrollExtent;

Obviously there is something wrong just by looking at it...

The same fix for the issue would be :

  @override
  double get minScrollExtent => _minScrollExtent;
  double _minScrollExtent = 0.0;

  @override
  double get maxScrollExtent => _maxScrollExtent;
  double _maxScrollExtent = 0.0;

Hope this will get a bit more attention.

@bounty1342

This comment has been minimized.

@darshankawar
Copy link
Member

@bounty1342
Thanks for digging in. Yes, I am reopening this issue and labelling as applicable.

flutter doctor -v
[✓] Flutter (Channel stable, 2.0.6, on Mac OS X 10.15.4 19E2269 darwin-x64,
    locale en-GB)
    • Flutter version 2.0.6 at /Users/dhs/documents/fluttersdk/flutter
    • Framework revision 1d9032c7e1 (6 days ago), 2021-04-29 17:37:58 -0700
    • Engine revision 05e680e202
    • Dart version 2.12.3

[!] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)    

[✓] VS Code (version 1.55.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.20.0

[✓] Connected device (3 available)
	  • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 10 (API 29)
    • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
      • iOS 14.4.1
    • macOS (desktop)           • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)              • chrome                                   •
      web-javascript • Google Chrome 89.0.4389.114

! Doctor found issues in 1 category.

@darshankawar darshankawar reopened this May 6, 2021
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label May 6, 2021
@darshankawar darshankawar changed the title list_wheel_scroll_view.dart error loading images list_wheel_scroll_view.dart throws Null check operator used on a null value error while loading images May 6, 2021
@darshankawar darshankawar added f: scrolling Viewports, list views, slivers, etc. found in release: 2.0 Found to occur in 2.0 framework flutter/packages/flutter repository. See also f: labels. labels May 6, 2021
@darshankawar darshankawar added has reproducible steps The issue has been confirmed reproducible and is ready to work on and removed in triage Presently being triaged by the triage team labels May 6, 2021
@ghost
Copy link

ghost commented May 18, 2021

Still reproducible in 2.0.6
Is there at least a workaround?

@hyungtaecf
Copy link

Still reproducible in 2.0.6
Is there at least a workaround?

I don't know if it is applicable to your context, but I mentioned my workaround here #61228, that is very simple but it took me a lot of time to find it... Now it works fine for me.

I was trying to fix the issue for my app for hours! I tried a lot of stuff, and I decided to try one last stupid thing before giving up, but it ended up working in my case!!

I'm using FancyShimmerImage inside ListWheelScrollView, which is basically the CachedNetworkImage with a shimmer. I noticed the problem was only happening to me for the visible widgets in the ListWheelScrollView, but when scrolling to the parts where it starts hidden, those images were loading well. So I realized it happens just in the first rendering. Then I had what I thought was a stupid idea, that I set the errorWidget to be displayed in the CachedNetworkImage as the FancyShimmerImage itself, and it ended up that when it tries to load the image again it works.

@bounty1342
Copy link

The issue is due to the widget having no size. (loading a Network images for example)
A placeolder with a size should avoid this issue.

@rockingdice
Copy link

Met the same issue. Please solve it asap. I'm using CupertinoPicker and can reproduce this issue.

@rockingdice
Copy link

rockingdice commented May 21, 2021

FYI, I found a workaround:
Use a FutureBuilder. You can wrap your widget into it and it will show without the exception.
You might consider using a SynchronousFuture to make it not blink.

In the mean time we might expect the flutter team to fix it.

@Levi-Lesches
Copy link
Contributor

Now that the error has changed, I think this became a duplicate of #85867, which has less discussion. Or that is a duplicate of this, but one of them can be closed.

@bleroux
Copy link
Contributor

bleroux commented Nov 29, 2022

This issue is no more reproducible since Flutter 3.0.5.
Closing it as fixed by #96102 (found using git bisect).

@bleroux bleroux closed this as completed Nov 29, 2022
@bleroux bleroux added the r: fixed Issue is closed as already fixed in a newer version label Nov 29, 2022
@github-actions
Copy link

github-actions bot commented Mar 5, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console f: scrolling Viewports, list views, slivers, etc. found in release: 2.0 Found to occur in 2.0 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list r: fixed Issue is closed as already fixed in a newer version
Projects
Status: Issue closed with comment
Development

No branches or pull requests

10 participants