当前位置:   article > 正文

Flutter 制作输入框和键盘的弹窗_flutter 聊天输入框 保持键盘弹出

flutter 聊天输入框 保持键盘弹出

一个问题:怎么让输入框贴着键盘:
可用如下方法解决

Padding(
  padding: EdgeInsets.only(
    bottom: MediaQuery.of(context).viewInsets.bottom
  ),
  child: TextField(
  )
)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

但是想在row里面嵌套输入框
那就在textFidle外面套个Expanded

一个问题:弹窗没有状态,怎么setState:StatefulBuilder

我自己的代码

return Container(
      ///弹框大小
      child: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          Padding(
            padding: EdgeInsets.only(
                bottom: MediaQuery.of(context).viewInsets.bottom),
            child: Row(
              children: [
                Expanded(
                  child: Container(
                    padding: EdgeInsets.only(left: 20, right: 10),
                    margin: EdgeInsets.only(left: 15, right: 12, bottom: 25),
                    decoration: BoxDecoration(
                        color: Color(0xFF2D2D2D),
                        borderRadius: BorderRadius.circular(50)),
                    child: TextFormField(
                      maxLines: 1,
                      style: const TextStyle(color: Color(0xFFFFFFFF)),
                      controller: _Controller,
                      focusNode: _focusNode,
                      decoration: const InputDecoration(
                        //去除下划线
                        border: InputBorder.none,
                        hintText: "這裡還缺一條你的優質評論",
                        hintStyle: TextStyle(color: Color(0xFF666666)),
                      ),
                    ),
                  ),
                ),
                Container(
                  height: 30,
                  width: 30,
                  margin: const EdgeInsets.only(bottom: 25, right: 5),
                  decoration: const BoxDecoration(
                    image: DecorationImage(
                      image: AssetImage(
                          "assets/base_widgets/icon_dynamic_details_smiley.png"),
                      fit: BoxFit.fitWidth,
                    ),
                  ),
                ),
                if (canSeeButton)
                  GestureDetector(
                    onTap: () {
                      _focusNode.unfocus();
                    },
                    child: Container(
                      margin: EdgeInsets.only(left: 5, right: 10, bottom: 25),
                      padding: EdgeInsets.only(
                          left: 10, right: 10, top: 5, bottom: 5),
                      decoration: BoxDecoration(
                          color: Color(0xFFE6CFA1),
                          borderRadius: BorderRadius.circular(8)),
                      child: Text(
                        "发送",
                        style: TextStyle(fontSize: 16),
                      ),
                    ),
                  ),
              ],
            ),
          ),
        ],
      ),
    );
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/268677
推荐阅读
相关标签
  

闽ICP备14008679号