Make sure that a DecoratedBox doesn't crash in 0x0 environment (#180329)

This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the DecoratedBox
widget.
This commit is contained in:
Ahmed Mohamed Sameh 2025-12-31 03:51:15 +02:00 committed by GitHub
parent 5cd1f94844
commit 6954931bb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -779,6 +779,18 @@ void main() {
matchesGoldenFile('container.clipBehaviour.with.shadow.png'), matchesGoldenFile('container.clipBehaviour.with.shadow.png'),
); );
}); });
testWidgets('DecoratedBox does not crash at zero area', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox.shrink(child: DecoratedBox(decoration: BoxDecoration())),
),
),
);
expect(tester.getSize(find.byType(DecoratedBox)), Size.zero);
});
} }
class _MockPaintingContext extends Fake implements PaintingContext { class _MockPaintingContext extends Fake implements PaintingContext {