mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make sure that a SearchAnchor doesn't crash in 0x0 environment (#177749)
This is my attempt to handle https://github.com/flutter/flutter/issues/6537 for the SearchAnchor widget. --------- Co-authored-by: Victor Sanni <victorsanniay@gmail.com> Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This commit is contained in:
parent
f64ddb8cb8
commit
12b5c1cfdf
@ -4281,6 +4281,29 @@ void main() {
|
||||
expect(viewTextField.smartQuotesType, SmartQuotesType.disabled);
|
||||
});
|
||||
|
||||
testWidgets('SearchAnchor does not crash at zero area', (WidgetTester tester) async {
|
||||
tester.view.physicalSize = Size.zero;
|
||||
final SearchController controller = SearchController();
|
||||
addTearDown(controller.dispose);
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Center(
|
||||
child: SearchAnchor(
|
||||
searchController: controller,
|
||||
builder: (_, _) => const Text('X'),
|
||||
suggestionsBuilder: (_, _) => <Widget>[const Text('Y')],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.getSize(find.byType(SearchAnchor)), Size.zero);
|
||||
controller.selection = const TextSelection.collapsed(offset: 0);
|
||||
await tester.pump();
|
||||
expect(find.byType(Text), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('SearchBar does not crash at zero area', (WidgetTester tester) async {
|
||||
tester.view.physicalSize = Size.zero;
|
||||
final TextEditingController controller = TextEditingController(text: 'X');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user