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

ScrollablePositionedList: Assert when reuse the ScrollablePositionedList #24

Closed
rockingdice opened this issue Sep 9, 2019 · 14 comments
Closed
Assignees
Labels
p: scrollable_positioned_list Related to package:scrollable_positioned_list SPL - pr SPL-lifecycle ScrollablePositonedList issues with state when reusing or other lifecycle issues SPL-warning ScrollablePositonedList warnings but not breaking

Comments

@rockingdice
Copy link

Well, it's not breaking things, just an assert triggered when dispose.

flutter doctor -v:

[✓] Flutter (Channel master, v1.10.1-pre.42, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)
    • Flutter version 1.10.1-pre.42 at /Users/li9s/github/flutter
    • Framework revision 681178ab45 (71 minutes ago), 2019-09-09 16:47:49 +0800
    • Engine revision c9ea4dba8d
    • Dart version 2.5.0 (build 2.5.0-dev.4.0 ec7ec4ecf7)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    • Android SDK at /Users/li9s/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.0
    • ANDROID_HOME = /Users/li9s/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/li9s/Library/Android/sdk
    • Java binary at: /Applications/Dev/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Dev/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.1

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Dev/Android Studio.app/Contents
    • Flutter plugin version 36.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Dev/Android Studio.app/Contents
    • Flutter plugin version 36.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
    • IntelliJ at /Applications/Dev/IntelliJ IDEA.app
    • Flutter plugin version 37.1.3
    • Dart plugin version 191.7830

[✓] Connected device (1 available)
    • LON AL00 • TEV0216C22001731 • android-arm64 • Android 9 (API 28)

I/flutter (12153): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (12153): The following assertion was thrown while finalizing the widget tree:
I/flutter (12153): 'package:mhwo/third_party/scrollable_positioned_list/scrollable_positioned_list.dart': Failed
I/flutter (12153): assertion: line 157 pos 12: '_scrollableListState != null': is not true.
I/flutter (12153): 
I/flutter (12153): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (12153): more information in this error message to help you determine and fix the underlying cause.
I/flutter (12153): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (12153):   https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (12153): 
I/flutter (12153): When the exception was thrown, this was the stack:
I/flutter (12153): #2      ItemScrollController._detach (package:mhwo/third_party/scrollable_positioned_list/scrollable_positioned_list.dart:157:12)
I/flutter (12153): #3      _ScrollablePositionedListState.dispose (package:mhwo/third_party/scrollable_positioned_list/scrollable_positioned_list.dart:192:34)
I/flutter (12153): #4      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4135:12)
I/flutter (12153): #5      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1738:13)
I/flutter (12153): #6      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #7      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3983:14)
I/flutter (12153): #8      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
I/flutter (12153): #9      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #10     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3983:14)
I/flutter (12153): #11     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
I/flutter (12153): #12     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #13     MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5218:16)
I/flutter (12153): #14     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
I/flutter (12153): #15     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #16     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3983:14)
I/flutter (12153): #17     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
I/flutter (12153): #18     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #19     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3983:14)
I/flutter (12153): #20     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
@ricardochen
Copy link

Did you add the property itemScrollController inside the builder?

ScrollablePositionedList.builder( itemCount: 500, itemBuilder: (context, index) => Text('Item $index'), itemScrollController: itemScrollController, itemPositionListener: itemPositionListener, );

@tarobins
Copy link
Collaborator

@rockingdice I haven't been able to repo the issue. Do you have sample code available?

@rockingdice
Copy link
Author

@tarobins I'll try to make a repo project for you.

@iota9star
Copy link

@tarobins same problems

jumpTo

jumpTo
jumpTo

scrollTo

scrollTo
scrollTo

@tarobins
Copy link
Collaborator

I was trying to repo this issue with the withControl branch of this project: https://github.com/tarobins/page_list_demo/tree/withControl

The app has two pages with a list on each and a button that jumps the first list to 100. The button only controller the first list, and when the second list is showing, and you press the button you do get an error, kind of expectedly. Is this the situation you were running into or something else?

Thanks

Tom

@tarobins
Copy link
Collaborator

as an aside, I ran into this while trying the above #43

@tarobins tarobins changed the title Assert when reuse the ScrollablePositionedList ScrollablePositionedList: Assert when reuse the ScrollablePositionedList Dec 21, 2019
@sachaarbonel
Copy link

I had the same problem when using ScrollablePositionedList in a stateless widget. Converting it to a stateful widget did the trick

@sajithtm002
Copy link

I had the same problem when using ScrollablePositionedList in a stateless widget. Converting it to a stateful widget did the trick

Also define ItemScrollController inside initState() method.

ItemScrollController _controller;
void initState() {
// TODO: implement initState
super.initState();
_controller = ItemScrollController();
}

@jamesderlin jamesderlin added the p: scrollable_positioned_list Related to package:scrollable_positioned_list label Apr 16, 2020
@tarobins tarobins added SPL-warning ScrollablePositonedList warnings but not breaking SPL-lifecycle ScrollablePositonedList issues with state when reusing or other lifecycle issues labels Apr 29, 2020
@tactical-retreat
Copy link

I also had this issue, as far as I can tell I'm using everything correctly. Converting the containing widget from Stateless to Statefull fixed it with no other changes.

@tarobins
Copy link
Collaborator

@nachoapps do you have an example of where it didn't work?

@tactical-retreat
Copy link

I do in my app, but it's not extracted to a reusable case right now. Also my flutter code is trash, so, sorry about that.

If you want to take a look, here's the commit that fixed it:
tactical-retreat/dadguide-flutter@065c3fd

Basically what I did here was create a Stack that automatically puts 'to bottom' and 'to top' buttons in the upper right/left hand corner, hovering over a list. With the regular ListView this is awful and slow, but with your widget super fast!

I'm using that stack widget here:
https://github.com/nachoapps/dadguide-flutter/blob/065c3fdae1a9a5e326c70029860eeeb835c940f3/lib/screens/monster/monster_list_tab.dart#L73

My app has bottom tabs, and the behavior I saw was clicking between tabs could semi-randomly cause a red screen of death.

@tarobins
Copy link
Collaborator

I think #119 will fix this issue. Once that PR is closed, please let me know if not.

tarobins pushed a commit to tarobins/flutter.widgets that referenced this issue May 18, 2020
Move itemScrollControllerDetachment to deactivate.

Fixes google#95
Fixes google#24

## Related Issues

google#95
google#24

Closes google#119

PiperOrigin-RevId: 311859101
tarobins added a commit to tarobins/flutter.widgets that referenced this issue May 18, 2020
## Description

Move itemScrollControllerDetachment to deactivate.

Fixes google#95
Fixes google#24

## Related Issues

google#95
google#24

Closes google#119

PiperOrigin-RevId: 311930043
@tactical-retreat
Copy link

Seems fixed in 1.6, thanks!

@diver2
Copy link

diver2 commented Dec 27, 2020

I'm having it back on 0.1.8...

The following assertion was thrown building Container:
'package:scrollable_positioned_list/src/scrollable_positioned_list.dart': Failed assertion: line 202 pos 12: '_scrollableListState == null': is not true.

The relevant error-causing widget was
Container
lib/widgets/dive_list.dart:198
When the exception was thrown, this was the stack
#2      ItemScrollController._attach
package:scrollable_positioned_list/src/scrollable_positioned_list.dart:202
#3      _ScrollablePositionedListState.initState
package:scrollable_positioned_list/src/scrollable_positioned_list.dart:241
#4      StatefulElement._firstBuild
package:flutter//widgets/framework.dart:4765
#5      ComponentElement.mount
package:flutter//widgets/framework.dart:4601
...     Normal element mounting (111 frames)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: scrollable_positioned_list Related to package:scrollable_positioned_list SPL - pr SPL-lifecycle ScrollablePositonedList issues with state when reusing or other lifecycle issues SPL-warning ScrollablePositonedList warnings but not breaking
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants