Skip to content

RenderFlex should not use defaultComputeDistanceToFirstActualBaseline to calculate its baseline in Axis.vertical #145739

@LongCatIsLooong

Description

@LongCatIsLooong

VerticalDirection.up reorders its children. This will be a breaking change.

  test('Vertical Flex Baseline', () {
    const BoxConstraints square = BoxConstraints.tightFor(width: 100.0, height: 100.0);
    final RenderConstrainedBox box1 = RenderConstrainedBox(
      additionalConstraints: square,
      child: RenderFlowBaselineTestBox()
        ..gridCount = 1
        ..baselinePlacer = (double height) => 10,
    );
    final RenderConstrainedBox box2 = RenderConstrainedBox(
      additionalConstraints: square,
      child: RenderFlowBaselineTestBox()
        ..gridCount = 1
        ..baselinePlacer = (double height) => 10,
    );
    final RenderFlex flex = RenderFlex(
      textDirection: TextDirection.ltr,
      children: <RenderBox>[box1, box2],
      direction: Axis.vertical,
    );
    layout(flex, phase: EnginePhase.paint);

    // We can't call the getDistanceToBaseline method directly. Check the dry
    // baseline instead, and in debug mode there are asserts that verify
    // the two methods return the same results.
    expect(flex.getDryBaseline(flex.constraints, TextBaseline.alphabetic), 10);

    flex.mainAxisAlignment = MainAxisAlignment.end;
    pumpFrame(phase: EnginePhase.paint);
    expect(flex.getDryBaseline(flex.constraints, TextBaseline.alphabetic), 410);

    flex.verticalDirection = VerticalDirection.up;
    pumpFrame(phase: EnginePhase.paint);
    expect(flex.getDryBaseline(flex.constraints, TextBaseline.alphabetic), 10);

    flex.mainAxisAlignment = MainAxisAlignment.start;
    pumpFrame(phase: EnginePhase.paint);
    expect(flex.getDryBaseline(flex.constraints, TextBaseline.alphabetic), 410);
  });

Metadata

Metadata

Labels

a: layoutSystemChrome and Framework's Layout Issuesframeworkflutter/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