简体   繁体   English

键盘启动时如何避免页面滚动向上滚动

[英]How to avoid flutter page scroll up when the keyboard comes up

I want to get input from these TextField . 我想从这些TextField获取输入。 When I focus the TextField the keyboard comes up and page scroll up. 当我将TextField聚焦时,键盘会出现,页面会向上滚动。 I do not need that scrolling. 我不需要滚动。 How can I avoid this? 如何避免这种情况?

普通视图

在TextField聚焦之后

To get better idea follow this reference link : https://api.flutter.dev/flutter/material/Scaffold/resizeToAvoidBottomInset.html 要获得更好的主意,请遵循以下参考链接: https : //api.flutter.dev/flutter/material/Scaffold/resizeToAvoidBottomInset.html

 return Scaffold(
      resizeToAvoidBottomInset : false,
      body: Container(),
    )

Use 采用

Scaffold(
  resizeToAvoidBottomInset: false,
  ...
)

From docs: 从文档:

For example, if there is an onscreen keyboard displayed above the scaffold, the body can be resized to avoid overlapping the keyboard, which prevents widgets inside the body from being obscured by the keyboard. 例如,如果在支架上方显示了屏幕键盘,则可以调整主体的大小以避免键盘重叠,这可以防止键盘遮盖主体内部的小部件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM