打开键盘时如何推送所有内容 [英] how to push all content up when open keyboard

查看:101
本文介绍了打开键盘时如何推送所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打开键盘时是否可以向上推所有内容? (不仅textField区域,整个页面都向上推)

Is it possible to push all content up when open keyboard? (not only textField area, whole page push up)

   showModalBottomSheet(
       context: context,
       builder: (BuildContext context) {
            return BottomSheet();
       },
   isScrollControlled: true);

BottomSheet类

class BottomSheet extends StatefulWidget {
  @override
  _BottomSheetState createState() => _BottomSheetState();
}

class _BottomSheetState extends State<BottomSheet> {

  @override
  Widget build(BuildContext context) {
    return
      SingleChildScrollView(
        padding: EdgeInsets.only(
            bottom: MediaQuery.of(context).viewInsets.bottom),
            child: Container(
                child: Column(
                  children: <Widget>[...

我想喜欢这种俯卧撑,

但是当前输出是

推荐答案

您可以简单地给出小部件的位置为 MediaQuery.of(context).viewInsets.bottom 如果您正在使用堆栈。

You can simply give the widget a bottom position of MediaQuery.of(context).viewInsets.bottom if you are using a stack.

在您的情况下,将 margin:设置为 MediaQuery.of(context ).viewInsets.bottom 而不是填充。

In your case, set margin : to MediaQuery.of(context).viewInsets.bottom instead of padding.

这篇关于打开键盘时如何推送所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆