@@ -648,6 +648,53 @@ void main() {
648648 expect (box2.localToGlobal (Offset .zero).dy, 0.0 );
649649 });
650650
651+ test ('Vertical Flex Baseline' , () {
652+ const BoxConstraints square = BoxConstraints .tightFor (width: 100.0 , height: 100.0 );
653+ final RenderConstrainedBox box1 = RenderConstrainedBox (
654+ additionalConstraints: square,
655+ child: RenderFlowBaselineTestBox ()
656+ ..gridCount = 1
657+ ..baselinePlacer = (double height) => 10 ,
658+ );
659+ final RenderConstrainedBox box2 = RenderConstrainedBox (
660+ additionalConstraints: square,
661+ child: RenderFlowBaselineTestBox ()
662+ ..gridCount = 1
663+ ..baselinePlacer = (double height) => 10 ,
664+ );
665+ RenderConstrainedBox filler () => RenderConstrainedBox (additionalConstraints: square);
666+ final RenderFlex flex = RenderFlex (
667+ textDirection: TextDirection .ltr,
668+ children: < RenderBox > [
669+ filler (),
670+ box1,
671+ filler (),
672+ box2,
673+ filler (),
674+ ],
675+ direction: Axis .vertical,
676+ );
677+ layout (flex, phase: EnginePhase .paint);
678+ final double flexHeight = flex.size.height;
679+
680+ // We can't call the getDistanceToBaseline method directly. Check the dry
681+ // baseline instead, and in debug mode there are asserts that verify
682+ // the two methods return the same results.
683+ expect (flex.getDryBaseline (flex.constraints, TextBaseline .alphabetic), 100 + 10 );
684+
685+ flex.mainAxisAlignment = MainAxisAlignment .end;
686+ pumpFrame (phase: EnginePhase .paint);
687+ expect (flex.getDryBaseline (flex.constraints, TextBaseline .alphabetic), flexHeight - 400 + 10 );
688+
689+ flex.verticalDirection = VerticalDirection .up;
690+ pumpFrame (phase: EnginePhase .paint);
691+ expect (flex.getDryBaseline (flex.constraints, TextBaseline .alphabetic), 300 + 10 );
692+
693+ flex.mainAxisAlignment = MainAxisAlignment .start;
694+ pumpFrame (phase: EnginePhase .paint);
695+ expect (flex.getDryBaseline (flex.constraints, TextBaseline .alphabetic), flexHeight - 200 + 10 );
696+ });
697+
651698 group ('Intrinsics' , () {
652699 test ('main axis intrinsics with RenderAspectRatio 1' , () {
653700 const BoxConstraints square = BoxConstraints .tightFor (width: 100.0 , height: 100.0 );
0 commit comments