SearchBar.scrollPadding (#152635)
Pass through the missing scrollPadding parameter for SearchBar and SearchAnchor.bar.
This commit is contained in:
parent
e08b0a56f9
commit
67a958568e
@ -184,6 +184,7 @@ class SearchAnchor extends StatefulWidget {
|
||||
required SuggestionsBuilder suggestionsBuilder,
|
||||
TextInputAction? textInputAction,
|
||||
TextInputType? keyboardType,
|
||||
EdgeInsets scrollPadding,
|
||||
}) = _SearchAnchorWithSearchBar;
|
||||
|
||||
/// Whether the search view grows to fill the entire screen when the
|
||||
@ -1033,6 +1034,7 @@ class _SearchAnchorWithSearchBar extends SearchAnchor {
|
||||
required super.suggestionsBuilder,
|
||||
super.textInputAction,
|
||||
super.keyboardType,
|
||||
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
|
||||
}) : super(
|
||||
viewHintText: viewHintText ?? barHintText,
|
||||
headerHeight: viewHeaderHeight,
|
||||
@ -1066,6 +1068,7 @@ class _SearchAnchorWithSearchBar extends SearchAnchor {
|
||||
textCapitalization: textCapitalization,
|
||||
textInputAction: textInputAction,
|
||||
keyboardType: keyboardType,
|
||||
scrollPadding: scrollPadding,
|
||||
);
|
||||
}
|
||||
);
|
||||
@ -1186,6 +1189,7 @@ class SearchBar extends StatefulWidget {
|
||||
this.autoFocus = false,
|
||||
this.textInputAction,
|
||||
this.keyboardType,
|
||||
this.scrollPadding = const EdgeInsets.all(20.0),
|
||||
});
|
||||
|
||||
/// Controls the text being edited in the search bar's text field.
|
||||
@ -1327,6 +1331,9 @@ class SearchBar extends StatefulWidget {
|
||||
/// Defaults to the default value specified in [TextField].
|
||||
final TextInputType? keyboardType;
|
||||
|
||||
/// {@macro flutter.widgets.editableText.scrollPadding}
|
||||
final EdgeInsets scrollPadding;
|
||||
|
||||
@override
|
||||
State<SearchBar> createState() => _SearchBarState();
|
||||
}
|
||||
@ -1467,6 +1474,7 @@ class _SearchBarState extends State<SearchBar> {
|
||||
textCapitalization: effectiveTextCapitalization,
|
||||
textInputAction: widget.textInputAction,
|
||||
keyboardType: widget.keyboardType,
|
||||
scrollPadding: widget.scrollPadding,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -1642,12 +1642,14 @@ class EditableText extends StatefulWidget {
|
||||
final Brightness keyboardAppearance;
|
||||
|
||||
/// {@template flutter.widgets.editableText.scrollPadding}
|
||||
/// Configures padding to edges surrounding a [Scrollable] when the Textfield scrolls into view.
|
||||
/// Configures the padding for the edges surrounding a [Scrollable] when the
|
||||
/// text field scrolls into view.
|
||||
///
|
||||
/// When this widget receives focus and is not completely visible (for example scrolled partially
|
||||
/// off the screen or overlapped by the keyboard)
|
||||
/// then it will attempt to make itself visible by scrolling a surrounding [Scrollable], if one is present.
|
||||
/// This value controls how far from the edges of a [Scrollable] the TextField will be positioned after the scroll.
|
||||
/// When this widget receives focus and is not completely visible (for example
|
||||
/// scrolled partially off the screen or overlapped by the keyboard), then it
|
||||
/// will attempt to make itself visible by scrolling a surrounding
|
||||
/// [Scrollable], if one is present. This value controls how far from the
|
||||
/// edges of a [Scrollable] the TextField will be positioned after the scroll.
|
||||
///
|
||||
/// Defaults to EdgeInsets.all(20.0).
|
||||
/// {@endtemplate}
|
||||
|
@ -3274,6 +3274,43 @@ void main() {
|
||||
|
||||
expect(find.text('Item - 1'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('SearchBar.scrollPadding is passed through to EditableText', (WidgetTester tester) async {
|
||||
const EdgeInsets scrollPadding = EdgeInsets.zero;
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Material(
|
||||
child: SearchBar(
|
||||
scrollPadding: scrollPadding,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(EditableText), findsOneWidget);
|
||||
final EditableText editableText = tester.widget(find.byType(EditableText));
|
||||
expect(editableText.scrollPadding, scrollPadding);
|
||||
});
|
||||
|
||||
testWidgets('SearchAnchor.bar.scrollPadding is passed through to EditableText', (WidgetTester tester) async {
|
||||
const EdgeInsets scrollPadding = EdgeInsets.zero;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: SearchAnchor.bar(
|
||||
suggestionsBuilder: (BuildContext context, SearchController controller) {
|
||||
return <Widget>[];
|
||||
},
|
||||
scrollPadding: scrollPadding,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(EditableText), findsOneWidget);
|
||||
final EditableText editableText = tester.widget(find.byType(EditableText));
|
||||
expect(editableText.scrollPadding, scrollPadding);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> checkSearchBarDefaults(WidgetTester tester, ColorScheme colorScheme, Material material) async {
|
||||
|
Loading…
x
Reference in New Issue
Block a user