gpt4 book ai didi

flutter - 在滚动时关闭键盘?

转载 作者:IT王子 更新时间:2023-10-29 07:12:40 26 4
gpt4 key购买 nike

我在应用程序中有文本字段。点击文本字段时会自动打开键盘。但是当在它后面的列表(firebaseAnimatedList)上向下滚动时,键盘不会被关闭。这不正常,在 iOS 上是个大问题,因为无法按返回按钮关闭。

谁知道怎么解决?

最佳答案

这是我做的:

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

关于flutter - 在滚动时关闭键盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54259367/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com