Reputation: 2353
I have textfield in app. This open keyboard automatic when tap on textfield. But when scroll down on list (firebaseAnimatedList) behind it keyboard is not dismiss. This not normal and is big problem on iOS because cannot press back button to dismiss.
Anyone know how to solve?
Upvotes: 1
Views: 2642
Reputation: 975
you can use keyboardDismissBehavior.
return ListView.builder(
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
Upvotes: 3
Reputation: 639
This is what gives you the desired effect:
NotificationListener(
onNotification: (ScrollNotification scrollInfo) {
if (scrollInfo is ScrollUpdateNotification) {
if (scrollInfo.scrollDelta >= 20.0) {
FocusScope.of(context).requestFocus(FocusNode());
}
}
},
child: new FirebaseAnimatedList ...)
Upvotes: 0
Reputation: 68
This is what I did:
NotificationListener(
onNotification: (t) {
if (t is UserScrollNotification) {
FocusScope.of(context).requestFocus(FocusNode());
}
},
child: ListView.builder(
itemBuilder: (_, i) => Container(),
itemCount: items.length,
),
);
Attaching a ScrollListener
didn't work for me because Android uses ClampingScrollPhysics
and it will only receive the scroll event if the ListView items are longer than the parent. However, a NotificationListener
will receive all events bubbled up including UserScrollNotification
.
Upvotes: 3
Reputation: 4648
You can put the following code in your lists scroll listener.
FocusScope.of(context).requestFocus(new FocusNode());
Upvotes: 0