Make sure that a TextFormField doesn't crash in 0x0 environment (#178233)

This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the TextFormField
widget.
This commit is contained in:
Ahmed Mohamed Sameh 2025-11-11 02:47:14 +02:00 committed by GitHub
parent 5afc762e41
commit 1b40c01079
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1875,4 +1875,21 @@ void main() {
.copyWith(enabled: true, hintMaxLines: 1);
expect(decorator.decoration, expectedDecoration);
});
testWidgets('TextFormField does not crash at zero area', (WidgetTester tester) async {
tester.view.physicalSize = Size.zero;
final TextEditingController controller = TextEditingController(text: 'X');
addTearDown(tester.view.reset);
addTearDown(controller.dispose);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(child: TextFormField(controller: controller)),
),
),
);
expect(tester.getSize(find.byType(TextFormField)), Size.zero);
controller.selection = const TextSelection.collapsed(offset: 0);
tester.pump();
});
}