Skip to content

ScrollMetricsNotification does not work with SingleChildScrollView #102181

@Piinks

Description

@Piinks

@darrenaustin found this - thanks!
In looking at why the fix for #101416 was reverted, the change that fixed it (#101460) exposed a separate bug. SingleChildScrollView does not respond to ScrollMetricsNotifications beyond the first initial notification.

This is because ScrollMetricsNotifications are considered for dispatch during ScrollPosition.applyContentDimensions. This is called during the course of performLayout of the RenderViewport, which lays out children lazily, causing ScrollPosition.applyContentDimensions to be called regularly in the course of scrolling. This function returns true or false to indicate if we need to perform layout again.

SingleChildScrollView has its own viewport render object, and only performs layout once (since it only has one child), so it never calls applyContentDimensions after the initial layout.

We should be able to call applyContentDimensions in the already existing _RenderSingleChildViewport._hasScrolled, it will return true and not cause additional layouts.

We should also check and see if other custom viewports have the same bug and add a comment indicating that if it changes in one, it should be updated in the rest.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listf: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions