<>flutter 键盘与singleChildScrollview配合使用

隐藏键盘一般是点击屏幕(非textField)位置。但遇到复杂页面,类似scrollview的,有可能需要滑动隐藏键盘。

flutter不用设置任何的位置跳转,只要点击textField就会自动滑到对应的位置。

<>滑动隐藏键盘

使用通知监听NotificationListener里对scrollview的滑动事件监听ScrollUpdateNotification
//滑动隐藏键盘 return NotificationListener<ScrollUpdateNotification>(
onNotification: (ScrollUpdateNotification notification) { if
(notification.dragDetails != null) { _keyBoardFocus.unfocus(); } return true;
}, child:
<>点击隐藏键盘

点击屏幕取消键盘,直接在最外层套一个GestureDetector()的点击事件onTap判断就可,GestureDetector()
也有滑动事件,但都不好用,没有滑动中的判断,只有滑动前和滑动后的判断

final GestureDragDownCallback? onPanDown;

final GestureDragStartCallback? onPanStart;

final GestureDragUpdateCallback? onPanUpdate; 这个是滑动期间,但在scollview里不管用。

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信