在 flutter 中单击 enter 后键盘关闭和多行问题

Keyboard dismissed and Multiline issue after clicking enter in flutter

我正在尝试创建允许用户使用多行 TextFormField 仅在 doubleTap() 上键入的应用程序。所以,我使用的是 InkWell,但是当用户点击回车后,我不会换行。请检查这个简单的函数。

getTextFormFieldWithInkwell() {
return Container(
  height: 200,
  width: 200,
  child: InkWell(
    onTap: () {
      print("onTap");
    },
    onDoubleTap: () {
      // some func that enables user to write text
      print("onTap");
    },
    child: TextFormField(
      keyboardType: TextInputType.multiline,
      maxLines: 10,
      textInputAction: TextInputAction.newline,
      onChanged: (String t) {
        print("onChanged");
        print(t);
      },
    ),
  ),
);
}

GITHUB

中的类似未解决问题

InkWell 替换为 TapGesture 将解决此问题。

 getTextFormFieldWithInkwell() {
  return Center(
    child: Container(
      height: 400,
      width: 400,
      child: GestureDetector(
        onTap: () {
          print("onTap");
        },
        child: TextFormField(
          controller: controller1,
          keyboardType: TextInputType.multiline,
          maxLines: 10,
          textInputAction: TextInputAction.newline,
          onChanged: (String t) {
            print("onChanged");
            print(t);
          },
        ),
      ),
    ),
  );
}