【问题标题】:Changing height of container with TextField使用 TextField 更改容器的高度
【发布时间】:2020-08-02 07:57:42
【问题描述】:

如何更改容器的高度并自动将光标移到下一行填充一行(类似于我们输入消息的 WhatsApp)? 这是我的代码: 定位( 底部: MediaQuery.of(context).size.height*0.03 , 孩子:容器( 宽度:MediaQuery.of(context).size.width,

          ),
          child: Padding(
            padding: EdgeInsets.symmetric(horizontal: 8.0),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                CircleAvatar(
                  backgroundColor: Colors.white,
                  child: IconButton(
                    onPressed: (){

                    },
                    icon: Icon(Icons.add),
                  ),
                ),
                EditableText(
                  expands: true,
                  maxLines: null,
                  minLines: null,
                  style: kTextStyle.copyWith(fontSize: 18.0),
                  cursorColor: Colors.white,
                  scrollPhysics: AlwaysScrollableScrollPhysics(),
                  enableSuggestions: true,
                  controller: _chattextcontroller,
                  backgroundCursorColor: Colors.grey,
                  focusNode: FocusNode(),

                ),
                Expanded(
                  child: IconButton(
                    onPressed: (){

                    },
                    icon: Icon(Icons.send,
                 ),
                  ),
                )
              ],
            ),
          ),
        ),
      )

【问题讨论】:

    标签: flutter


    【解决方案1】:

    使用EditableText 小部件:

    EditableText(
        expands: true,
        maxLines: null,
        minLines: null,
        //other required params
    ),
    

    【讨论】:

    • 请检查我在问题中编辑的代码。我不知道为什么,但正在显示空白屏幕。我已将整个代码放在 Positioned 小部件中。
    • 我认为它可以工作,但你看不到可编辑文本 bcz 没有背景颜色尝试将其包装在容器中并给容器一个颜色,你会看到它在哪里
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 2015-01-05
    • 2022-06-23
    相关资源
    最近更新 更多