Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Slider relies on brittle paint order to work properly #98770

Open
@goderbauer

Description

@goderbauer

The material Slider widget relies on the order in which nodes get precessed during PAINT in order to present itself visually correctly. That's brittle.

Here's the problem: In its paint method _RenderSlider configures the paintValueIndicator painter...

_state.paintValueIndicator = (PaintingContext context, Offset offset) {

... which is used in the paint method of _RenderValueIndicator:

_state.paintValueIndicator?.call(context, offset);

This only works if _RenderSlider is processed before _RenderValueIndicator during PAINT. Otherwise, _RenderValueIndicator.paint will not see the painter configured by _RenderSlider.paint and instead paint with an outdated painter.

Since nodes are processed from deepest to shallowest, this works fine when _RenderSlider is deeper in the tree than _RenderValueIndicator and breaks otherwise. It will also break when the order in which we process nodes during PAINT is flipped around as we did in #98219, which may give us some performance benefits. That PR saw breakages in google3 because of the problem described here (see b/219153804).

Long story short: Slider should not relay on the somewhat brittle order in which nodes get processed during PAINT.

Side node: We should also add a test for this to the framework since this was only caught during a google3 roll. Done: #98772

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions