Unverified Commit e0afee5b authored by Raouf Rahiche's avatar Raouf Rahiche Committed by GitHub

add ScrollViewKeyboardDismissBehavior to CustomScrollView constructor (#66014)

parent 36a6ef64
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment