zero-sized RenderConstraintsTransformBox respects clipBehavior (#147349)
Fixes https://github.com/flutter/flutter/issues/146840
This commit is contained in:
@@ -896,9 +896,7 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
|
||||
|
||||
@override
|
||||
void paint(PaintingContext context, Offset offset) {
|
||||
// There's no point in drawing the child if we're empty, or there is no
|
||||
// child.
|
||||
if (child == null || size.isEmpty) {
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -919,6 +917,9 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
|
||||
|
||||
// Display the overflow indicator if clipBehavior is Clip.none.
|
||||
assert(() {
|
||||
if (size.isEmpty) {
|
||||
return true;
|
||||
}
|
||||
switch (clipBehavior) {
|
||||
case Clip.none:
|
||||
paintOverflowIndicator(context, offset, _overflowContainerRect, _overflowChildRect);
|
||||
|
||||
@@ -503,6 +503,23 @@ void main() {
|
||||
// At least 2 lines.
|
||||
expect(constrainedHeight, greaterThanOrEqualTo(2 * unconstrainedHeight));
|
||||
});
|
||||
|
||||
test('paints even when its size is empty', () {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/146840.
|
||||
final RenderParagraph child = RenderParagraph(
|
||||
const TextSpan(text: ''),
|
||||
textDirection: TextDirection.ltr,
|
||||
);
|
||||
final RenderConstraintsTransformBox box = RenderConstraintsTransformBox(
|
||||
alignment: Alignment.center,
|
||||
textDirection: TextDirection.ltr,
|
||||
constraintsTransform: (BoxConstraints constraints) => constraints.copyWith(maxWidth: double.infinity),
|
||||
child: child,
|
||||
);
|
||||
|
||||
layout(box, constraints: BoxConstraints.tight(Size.zero), phase: EnginePhase.paint);
|
||||
expect(box, paints..paragraph());
|
||||
});
|
||||
});
|
||||
|
||||
test ('getMinIntrinsicWidth error handling', () {
|
||||
|
||||
Reference in New Issue
Block a user