mirror of
https://github.com/flutter/flutter.git
synced 2026-02-11 05:17:36 +08:00
add ScrollViewKeyboardDismissBehavior to CustomScrollView constructor (#66014)
This commit is contained in:
parent
36a6ef6486
commit
e0afee5b13
@ -596,6 +596,7 @@ class CustomScrollView extends ScrollView {
|
||||
this.slivers = const <Widget>[],
|
||||
int? semanticChildCount,
|
||||
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
|
||||
ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
|
||||
String? restorationId,
|
||||
Clip clipBehavior = Clip.hardEdge,
|
||||
}) : super(
|
||||
@ -611,6 +612,7 @@ class CustomScrollView extends ScrollView {
|
||||
cacheExtent: cacheExtent,
|
||||
semanticChildCount: semanticChildCount,
|
||||
dragStartBehavior: dragStartBehavior,
|
||||
keyboardDismissBehavior: keyboardDismissBehavior,
|
||||
restorationId: restorationId,
|
||||
clipBehavior: clipBehavior,
|
||||
);
|
||||
|
||||
@ -799,6 +799,45 @@ void main() {
|
||||
log.clear();
|
||||
});
|
||||
|
||||
testWidgets('CustomScrollView dismiss keyboard onDrag test', (WidgetTester tester) async {
|
||||
final List<FocusNode> focusNodes = List<FocusNode>.generate(50, (int i) => FocusNode());
|
||||
|
||||
await tester.pumpWidget(textFieldBoilerplate(
|
||||
child: CustomScrollView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
slivers: <Widget>[
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
focusNodes.map((FocusNode focusNode) {
|
||||
return Container(
|
||||
height: 50,
|
||||
color: Colors.green,
|
||||
child: TextField(
|
||||
focusNode: focusNode,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
)
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
final Finder finder = find.byType(TextField).first;
|
||||
final TextField textField = tester.widget(finder);
|
||||
await tester.showKeyboard(finder);
|
||||
expect(textField.focusNode.hasFocus, isTrue);
|
||||
|
||||
await tester.drag(finder, const Offset(0.0, -40.0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(textField.focusNode.hasFocus, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Can jumpTo during drag', (WidgetTester tester) async {
|
||||
final List<Type> log = <Type>[];
|
||||
final ScrollController controller = ScrollController();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user