Make sure that a TextButton doesn't crash in 0x0 environment (#178213)

This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the TextButton
widget.
This commit is contained in:
Ahmed Mohamed Sameh 2025-11-11 02:32:16 +02:00 committed by GitHub
parent ab919febb3
commit b705072f08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2680,4 +2680,17 @@ void main() {
// The button should still be focused.
expect(getButtonFocusNode().hasFocus, true);
});
testWidgets('TextButton does not crash at zero area', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Center(
child: SizedBox.shrink(
child: TextButton(onPressed: () {}, child: const Text('X')),
),
),
),
);
expect(tester.getSize(find.byType(TextButton)), Size.zero);
});
}