我在应用程序中有文本框。点击文本框时,此打开的键盘自动运行。但是,当在其后的列表(firebaseAnimatedList)上向下滚动时,键盘不会关闭。这是不正常的,并且在iOS上是个大问题,因为无法按返回按钮将其关闭。
有人知道如何解决吗?
答案 0 :(得分:2)
这就是我所做的:
NotificationListener(
onNotification: (t) {
if (t is UserScrollNotification) {
FocusScope.of(context).requestFocus(FocusNode());
}
},
child: ListView.builder(
itemBuilder: (_, i) => Container(),
itemCount: items.length,
),
);
附加ScrollListener
对我不起作用,因为Android使用ClampingScrollPhysics
,并且只有ListView项比父项长时,它才会接收滚动事件。但是,NotificationListener
将收到冒泡的所有事件,包括UserScrollNotification
。
答案 1 :(得分:0)
You can put the following code in your lists scroll listener.
FocusScope.of(context).requestFocus(new FocusNode());
答案 2 :(得分:0)
这就是您想要的效果:
ClassNotFoundException
答案 3 :(得分:0)
您可以使用keyboardDismissBehavior。
return ListView.builder(
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,