flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.18k stars 26.64k forks source link

Null check operator used on a null value while use animateToItem() #147398

Open Stiuk opened 2 weeks ago

Stiuk commented 2 weeks ago

Steps to reproduce

user the animateToItem()

Expected results

do not throw this error

Actual results

throw error 'Null check operator used on a null value'

Code sample

RxInt yearIndex = 0.obs;
FixedExtentScrollController yearScrollController = FixedExtentScrollController();

yearIndex.value = select.year - int.parse(yearList[0]);
yearScrollController.animateToItem(yearIndex.value, duration: const Duration(milliseconds: 1), curve: Curves.easeInOut);

Screenshots or Video

No response

Logs

Null check operator used on a null value

#0      ScrollPosition.minScrollExtent (package:flutter/src/widgets/scroll_position.dart:140)
#1      _FixedExtentScrollPosition.itemIndex (package:flutter/src/widgets/list_wheel_scroll_view.dart:392)
#2      _FixedExtentScrollPosition.copyWith (package:flutter/src/widgets/list_wheel_scroll_view.dart:413)
#3      ScrollPosition.didStartScroll (package:flutter/src/widgets/scroll_position.dart:891)
#4      ScrollPosition.beginActivity (package:flutter/src/widgets/scroll_position.dart:882)
#5      ScrollPositionWithSingleContext.beginActivity (package:flutter/src/widgets/scroll_position_with_single_context.dart:111)
#6      ScrollPositionWithSingleContext.animateTo (package:flutter/src/widgets/scroll_position_with_single_context.dart:192)
#7      FixedExtentScrollController.animateToItem (package:flutter/src/widgets/list_wheel_scroll_view.dart:271)
#8      DatePickerStartToEndController._setupData (package:yzm_flutter_driver/common/widgets/date_picker_start_to_end/controller.dart:120)
#9      DatePickerStartToEndController.onReady (package:yzm_flutter_driver/common/widgets/date_picker_start_to_end/controller.dart:59)
#10     DisposableInterface.onInit.<anonymous closure> (package:get/get_state_manager/src/rx_flutter/rx_disposable.dart:21)
#11     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1284)
#12     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1223)
#13     ApmWidgetsFlutterBinding.handleDrawFrame (package:umeng_apm_sdk/src/core/apm_widgets_flutter_binding.dart:25)
#14     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1072)
#15     _rootRun (dart:async/zone.dart:1399)
#16     _CustomZone.run (dart:async/zone.dart:1301)
#17     _CustomZone.runGuarded (dart:async/zone.dart:1209)
#18     _invoke (dart:ui/hooks.dart:144)
#19     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:359)

Flutter Doctor output

[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [版本 10.0.22631.3447], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[!] Android Studio (version 2023.2)
    X Unable to find bundled Java version.
[!] Android Studio (version 2023.3)
    X Unable to find bundled Java version.
[√] Connected device (3 available)
[√] Network resources

! Doctor found issues in 3 categories.
danagbemava-nc commented 2 weeks ago

You are using an older version of flutter. Kindly upgrade to the latest version of flutter stable (3.19.6) to see if you still experience this issue. If you do, please provide the updated output of flutter doctor -v along with a complete minimal reproducible code sample without any third-party packages so that we can properly investigate this.

Thank you

Stiuk commented 2 weeks ago

You are using an older version of flutter. Kindly upgrade to the latest version of flutter stable (3.19.6) to see if you still experience this issue. If you do, please provide the updated output of flutter doctor -v along with a complete minimal reproducible code sample without any third-party packages so that we can properly investigate this.

Thank you

got it,thks