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

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

问题描述

是否可以在打开键盘时将所有内容向上推送?(不只是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>[...

我想喜欢这个俯卧撑,

但是当前的输出是,

推荐答案

你可以简单地给widget一个MediaQuery.of(context).viewInsets.bottombottom位置> 如果您使用的是堆栈.

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天全站免登陆