当我将文本字段设置为 Flutter 中的下一行时,文本会上升

When I set the textfield to the next line in Flutter, the text goes up

我想去掉在文本字段中按回车键时上升的字母。我该怎么办?

这是代码的一部分。

Container(
                          child: TextField(
                            textAlign: TextAlign.center,
                            autofocus: true,
                            // controller: myController,
                            onChanged: (value) {
                              // print('$value');
                              setState(() {
                                mainText = value;
                              });
                            },
                            keyboardType: TextInputType.multiline,
                            minLines: 1,
                            maxLines: 10,
                            decoration: InputDecoration(
                              focusedBorder: InputBorder.none,
                              enabledBorder: InputBorder.none,
                              hintText: "짧은 글귀를 집필해주세요",
                              hintStyle:
                                  TextStyle(fontSize: 14, color: Colors.black),
                            ),
                          ),
                        )

根据您的提示文本,您只需要短文本,您可以通过仅与单行文本字段集成来实现

  Container(
      child: TextField(
        textAlign: TextAlign.center,
        autofocus: true,
        // controller: myController,
        onChanged: (value) {
          setState(() {
            mainText = value;
          });
        },
        keyboardType: TextInputType.text, // this is change
        textInputAction: TextInputAction.done, // this is change
        decoration: InputDecoration(
          focusedBorder: InputBorder.none,
          enabledBorder: InputBorder.none,
          hintText: "짧은 글귀를 집필해주세요",
          hintStyle: TextStyle(fontSize: 14, color: Colors.black),
        ),
      ),
    )

对于多行文本:

keyboardType: TextInputType.multiline,
maxLines: 5,
textInputAction: TextInputAction.newline,