颤动多行文本字段光标在键盘下方移动

时间:2021-02-27 10:36:37

标签: flutter textfield

我创建了一个文本字段并启用了多行,以便我可以添加段落。但问题是,当我输入更多段落时,光标会在键盘下方移动,我看不到我在输入什么。

但是,在查看整个文本时,文本字段确实会上下滚动,但是如何在键入时使光标始终位于键盘上方??

Container(
                  padding: EdgeInsets.symmetric(horizontal: 10),
                  width: width,
                  margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
                  child: Material(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(20.0),
                    elevation: 12.0,
                    child: Padding(
                      padding: const EdgeInsets.symmetric(
                          horizontal: 20.0, vertical: 10.0),
                      child: TextField(
                        focusNode: textFocusNode,
                        controller: textController,
                        decoration: InputDecoration.collapsed(
                          hintText: '',
                          hintStyle: TextStyle(fontSize: 20),
                          focusColor: Colors.black,
                        ),
                        scrollPadding: EdgeInsets.all(20.0),
                        keyboardType: TextInputType.multiline,
                        cursorColor: Colors.black,
                        maxLines: null,
                      ),
                    ),
                  ),
                ),

0 个答案:

没有答案