Make sure that a SearchBar doesn't crash in 0x0 environment (#177761)

This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the SearchBar widget.
This commit is contained in:
Ahmed Mohamed Sameh 2025-11-02 21:52:00 +02:00 committed by GitHub
parent 5e348fd892
commit 15d2e56b4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4280,6 +4280,22 @@ void main() {
expect(viewTextField.smartDashesType, SmartDashesType.disabled);
expect(viewTextField.smartQuotesType, SmartQuotesType.disabled);
});
testWidgets('SearchBar does not crash at zero area', (WidgetTester tester) async {
tester.view.physicalSize = Size.zero;
final TextEditingController controller = TextEditingController(text: 'X');
addTearDown(controller.dispose);
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Center(child: SearchBar(controller: controller)),
),
);
expect(tester.getSize(find.byType(SearchBar)), Size.zero);
controller.selection = const TextSelection.collapsed(offset: 0);
await tester.pump();
expect(find.text('X'), findsOne);
});
}
Future<void> checkSearchBarDefaults(