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
166.38k stars 27.56k forks source link

Error when combining scrolling and pull-to-refresh in Debug #144386

Closed egorozh closed 8 months ago

egorozh commented 8 months ago

Steps to reproduce

  1. Pull for a pull-to-refresh and scroll the content at the same time. (watch the video and the sample code)
  2. It is necessary to repeat the steps until the error occurs
  3. Perhaps the error is related to Closed Issue

Expected results

No Error

Actual results

Error: The following assertion was thrown while dispatching notifications for _StretchController:

look at the logs

Code sample

Code sample ```dart class MyHomePage extends StatelessWidget { const MyHomePage({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) => [ const SliverAppBar( title: Text("RefreshIndicator"), ), ], body: RefreshIndicator( onRefresh: () => Future.delayed(const Duration(seconds: 4)), child: CustomScrollView( slivers: [ SliverList.builder( itemCount: 30, itemBuilder: (context, index) => ListTile( title: Text("Title $index"), subtitle: Text("Subtitle $index"), ), ) ], ), ), ), ); } } ```

Screenshots or Video

Video demonstration https://github.com/flutter/flutter/assets/37664492/2d6803ff-dc29-4386-9d2a-479fcc8990c9

Logs

Logs ```console ======== Exception caught by foundation library ==================================================== The following assertion was thrown while dispatching notifications for _StretchController: Build scheduled during frame. While the widget tree was being built, laid out, and painted, a new frame was scheduled to rebuild the widget tree. This might be because setState() was called from a layout or paint callback. If a change is needed to the widget tree, it should be applied as the tree is being built. Scheduling a change for the subsequent frame instead results in an interface that lags behind by one frame. If this was done to make your build dependent on a size measured at layout time, consider using a LayoutBuilder, CustomSingleChildLayout, or CustomMultiChildLayout. If, on the other hand, the one frame delay is the desired effect, for example because this is an animation, consider scheduling the frame in a post-frame callback using SchedulerBinding.addPostFrameCallback or using an AnimationController to trigger the animation. When the exception was thrown, this was the stack: #0 WidgetsBinding._handleBuildScheduled. (package:flutter/src/widgets/binding.dart:854:9) #1 WidgetsBinding._handleBuildScheduled (package:flutter/src/widgets/binding.dart:877:6) #2 BuildOwner.scheduleBuildFor (package:flutter/src/widgets/framework.dart:2730:24) #3 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:5059:12) #4 State.setState (package:flutter/src/widgets/framework.dart:1223:15) #5 _AnimatedState._handleChange (package:flutter/src/widgets/transitions.dart:129:5) #6 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24) #7 AnimationLocalListenersMixin.notifyListeners (package:flutter/src/animation/listener_helpers.dart:161:19) #8 AnimationController.value= (package:flutter/src/animation/animation_controller.dart:395:5) #9 AnimationController.forward (package:flutter/src/animation/animation_controller.dart:491:7) #10 _StretchController._recede (package:flutter/src/widgets/overscroll_indicator.dart:921:24) #11 _StretchController.scrollEnd (package:flutter/src/widgets/overscroll_indicator.dart:894:7) #12 _StretchingOverscrollIndicatorState._handleScrollNotification (package:flutter/src/widgets/overscroll_indicator.dart:723:26) #13 _NotificationElement.onNotification (package:flutter/src/widgets/notification_listener.dart:130:38) #14 _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3320:18) #15 _NotificationNode.dispatchNotification (package:flutter/src/widgets/framework.dart:3323:13) #16 Element.dispatchNotification (package:flutter/src/widgets/framework.dart:4942:24) #17 Notification.dispatch (package:flutter/src/widgets/notification_listener.dart:60:13) #18 ScrollActivity.dispatchScrollEndNotification (package:flutter/src/widgets/scroll_activity.dart:114:63) #19 ScrollPosition.didEndScroll (package:flutter/src/widgets/scroll_position.dart:1030:15) #20 ScrollPosition.beginActivity (package:flutter/src/widgets/scroll_position.dart:996:9) #21 _NestedInnerBallisticScrollActivity.applyNewDimensions (package:flutter/src/widgets/nested_scroll_view.dart:1520:14) #22 ScrollPosition.applyNewDimensions (package:flutter/src/widgets/scroll_position.dart:706:15) #23 _NestedScrollPosition.applyNewDimensions (package:flutter/src/widgets/nested_scroll_view.dart:1467:11) #24 ScrollPosition.applyContentDimensions (package:flutter/src/widgets/scroll_position.dart:635:7) #25 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1468:20) #26 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #27 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #28 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:21) #29 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #30 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #31 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:21) #32 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #33 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #34 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:21) #35 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #36 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #37 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:21) #38 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #39 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #40 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:21) #41 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #42 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #43 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:21) #44 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #45 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #46 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:21) #47 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #48 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #49 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:21) #50 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1440:11) #51 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #52 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #53 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:52:11) #54 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:582:43) #55 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:609:12) #56 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #57 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11) #58 RenderSliverFillRemainingWithScrollable.performLayout (package:flutter/src/rendering/sliver_fill.dart:87:14) #59 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7) #60 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:601:13) #61 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1555:12) #62 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1464:20) #63 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2414:7) #64 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1051:18) #65 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1064:15) #66 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:582:23) #67 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:991:13) #68 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:448:5) #69 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1386:15) #70 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1311:9) #71 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1169:5) #72 _invoke (dart:ui/hooks.dart:312:13) #73 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:399:5) #74 _drawFrame (dart:ui/hooks.dart:283:31) The _StretchController sending notification was: _StretchController() ==================================================================================================== ```

Flutter Doctor output

Doctor output ```console [√] Flutter (Channel stable, 3.19.2, on Microsoft Windows [Version 10.0.22631.3155], locale ru-RU) • Flutter version 3.19.2 on channel stable at C:\flutter • Upstream repository https://github.com/flutter/flutter.gitищены. • Framework revision 7482962148 (2 days ago), 2024-02-27 16:51:22 -0500 • Engine revision 04817c99c9 • Dart version 3.3.0 • DevTools version 2.31.1 [√] Windows Version (Installed version of Windows is version 10 or higher) [!] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\Egorozh\AppData\Local\Android\sdk X cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. X Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.0) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.9.34607.119 • Windows 10 SDK version 10.0.22000.0 X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components: MSVC v142 - VS 2019 C++ x64/x86 build tools - If there are multiple build tool versions available, install the latest C++ CMake tools for Windows Windows 10 SDK [√] Android Studio (version 2023.1) • Android Studio at C:\Program Files\Android\Android Studio • 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 17.0.7+0-b2043.56-10550314) [√] VS Code (version 1.85.2) • VS Code at C:\Users\Egorozh\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.82.0 [√] Connected device (4 available) • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.3155] • Chrome (web) • chrome • web-javascript • Google Chrome 118.0.5993.118 • Edge (web) • edge • web-javascript • Microsoft Edge 122.0.2365.59 [√] Network resources • All expected network resources are available. ! Doctor found issues in 2 categories. ```
darshankawar commented 8 months ago

Thanks for the report @egorozh I was able to replicate after trying out few times, but looking at the error received, it seems to be similar to https://github.com/flutter/flutter/issues/104798, so you can follow-up in it for further updates. You can share your findings in that issue for better tracking. Closing this as a duplicate. If you disagree, write in comments and I'll reopen it.

github-actions[bot] commented 8 months ago

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.