fix: Add enabled property for search anchor named constructor (#161468)
fix: Add enabled property for search anchor named constructor Fixes: #161063 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --------- Co-authored-by: Qun Cheng <36861262+QuncCccccc@users.noreply.github.com>
This commit is contained in:
@@ -204,6 +204,7 @@ class SearchAnchor extends StatefulWidget {
|
||||
TextInputType? keyboardType,
|
||||
EdgeInsets scrollPadding,
|
||||
EditableTextContextMenuBuilder contextMenuBuilder,
|
||||
bool enabled,
|
||||
}) = _SearchAnchorWithSearchBar;
|
||||
|
||||
/// Whether the search view grows to fill the entire screen when the
|
||||
@@ -1187,6 +1188,7 @@ class _SearchAnchorWithSearchBar extends SearchAnchor {
|
||||
super.keyboardType,
|
||||
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
|
||||
EditableTextContextMenuBuilder contextMenuBuilder = SearchBar._defaultContextMenuBuilder,
|
||||
super.enabled,
|
||||
}) : super(
|
||||
viewHintText: viewHintText ?? barHintText,
|
||||
headerHeight: viewHeaderHeight,
|
||||
|
||||
@@ -3200,6 +3200,33 @@ void main() {
|
||||
expect(controller.value.text, initValue);
|
||||
});
|
||||
|
||||
testWidgets('Block entering text on disabled widget with SearchAnchor.bar', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
const String initValue = 'init';
|
||||
final TextEditingController controller = TextEditingController(text: initValue);
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: SearchAnchor.bar(
|
||||
suggestionsBuilder: (BuildContext context, SearchController controller) {
|
||||
return <Widget>[];
|
||||
},
|
||||
enabled: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const String testValue = 'abcdefghi';
|
||||
await tester.enterText(find.byType(SearchBar), testValue);
|
||||
expect(controller.value.text, initValue);
|
||||
});
|
||||
|
||||
testWidgets('Disabled SearchBar semantics node still contains value', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user