Unverified Commit d71bbfb4 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Implement preferPaintInterior correctly for _CompoundBorder (#129851)

parent 81d7297d
......@@ -840,7 +840,7 @@ class _CompoundBorder extends ShapeBorder {
}
@override
bool get preferPaintInterior => true;
bool get preferPaintInterior => borders.every((ShapeBorder border) => border.preferPaintInterior);
@override
void paint(Canvas canvas, Rect rect, { TextDirection? textDirection }) {
......
......@@ -402,4 +402,71 @@ void main() {
await tester.pumpWidget(buildWidget(border: allowedBorderDirectionalVariations, boxShape: BoxShape.circle));
expect(tester.takeException(), isNull);
});
test('Compound borders with differing preferPaintInteriors', () {
expect(ShapeWithInterior().preferPaintInterior, isTrue);
expect(ShapeWithoutInterior().preferPaintInterior, isFalse);
expect((ShapeWithInterior() + ShapeWithInterior()).preferPaintInterior, isTrue);
expect((ShapeWithInterior() + ShapeWithoutInterior()).preferPaintInterior, isFalse);
expect((ShapeWithoutInterior() + ShapeWithInterior()).preferPaintInterior, isFalse);
expect((ShapeWithoutInterior() + ShapeWithoutInterior()).preferPaintInterior, isFalse);
});
}
class ShapeWithInterior extends ShapeBorder {
@override
bool get preferPaintInterior => true;
@override
ShapeBorder scale(double t) {
return this;
}
@override
EdgeInsetsGeometry get dimensions => EdgeInsets.zero;
@override
Path getInnerPath(Rect rect, { TextDirection? textDirection }) {
return Path();
}
@override
Path getOuterPath(Rect rect, { TextDirection? textDirection }) {
return Path();
}
@override
void paintInterior(Canvas canvas, Rect rect, Paint paint, { TextDirection? textDirection }) { }
@override
void paint(Canvas canvas, Rect rect, { TextDirection? textDirection }) { }
}
class ShapeWithoutInterior extends ShapeBorder {
@override
bool get preferPaintInterior => false;
@override
ShapeBorder scale(double t) {
return this;
}
@override
EdgeInsetsGeometry get dimensions => EdgeInsets.zero;
@override
Path getInnerPath(Rect rect, { TextDirection? textDirection }) {
return Path();
}
@override
Path getOuterPath(Rect rect, { TextDirection? textDirection }) {
return Path();
}
@override
void paintInterior(Canvas canvas, Rect rect, Paint paint, { TextDirection? textDirection }) { }
@override
void paint(Canvas canvas, Rect rect, { TextDirection? textDirection }) { }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment