mponkin / fading_edge_scrollview

Flutter library for displaying fading edges on scroll views
BSD 3-Clause "New" or "Revised" License
43 stars 30 forks source link

ScrollController attached to multiple scroll views #23

Closed scris closed 1 year ago

scris commented 1 year ago

Triggering Way:

  1. I made a FadingEdgeScrollView.fromSingleChildScrollView with a ScrollController() and then nested it in a ListView.
  2. I placed a PieMenu(https://pub.dev/packages/pie_menu, which has a LongPress gesture bounden) as a parent of the FadingEdgeScrollView.
  3. When I did the long press, I was getting the ScrollController attached to multiple scroll views error.

Although involved, I think this problem is not connected with PieMenu, it's just one of the ways of triggering this error (triggerable by other done-by-user operations, too). The reason of the error is most probably affiliated with getting multiple positions.

Involved Version:

3.0.0, upon Flutter 3.16.

Full Error Output:

The following assertion was thrown during a scheduler callback:
ScrollController attached to multiple scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 158 pos 12: '_positions.length == 1'

When the exception was thrown, this was the stack: 
#2      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:158:12)
#3      _FadingEdgeScrollViewState._controllerIsReady (package:fading_edge_scrollview/src/fading_edge_scrollview.dart:202:45)
#4      _FadingEdgeScrollViewState._postFrameCallback (package:fading_edge_scrollview/src/fading_edge_scrollview.dart:210:9)
#5      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15)
#6      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1264:9)
#7      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:5)
#8      _invoke (dart:ui/hooks.dart:312:13)
#9      PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:383:5)
#10     _drawFrame (dart:ui/hooks.dart:283:31)
(elided 2 frames from class _AssertionError)

Solving Strategy:

I tested and found it solvable by https://stackoverflow.com/a/70672454/15439845. I'll make a pull request later.

mponkin commented 1 year ago

fixed in version 4.0.0