Skip to content

NestedScrollView scrollcontroller is not detached after being attached #41910

@mehmetf

Description

@mehmetf

Internal: b/141956880

In the "attach" function the parent (scrollcontroller) gets attached via coordinator.updateParent(). However the parent never gets detached in the "detach" function.

This has been causing some minor for us when we do widget tests. In one of our widget tests, the nestedscrollview gets rebuilt in from a left-to-right configuration to a right-to-left configuration.

The scrollcontroller inside the widget's state doesn't get detached when the widgets get rebuild, so the scrollcontroller now has two scroll positions when the widget gets rebuilt in a "right-to-left" configuration and we run into this:

ScrollController attached to multiple scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 112 pos 12: '_positions.length == 1'

Either the assertion indicates an error in the framework itself,
or we should provide substantially more information in this error
message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on
GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

When the exception was thrown, this was the stack:
#2      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:112:12)
#3      ScrollController.offset (package:flutter/src/widgets/scroll_controller.dart:120:24)

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: crashStack traces logged to the consolecustomer: quill (g3)f: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions