Ios Can';t退出文本域颤振
我需要一个框来插入和存储用户输入的一些信息,我正在使用“TextField”,所以我将“TextField”中的“maxLines”选项从默认值(1)更改为(2),当我想在这里插入一些文本时,我不能离开框,因为“Done”按钮更改为“return”阻止了我!键盘也被屏蔽了。 我这样做是因为我想要一个盒子,里面有一些文字(如描述),我可以移动到我想要的地方,并更改它的所有属性。 我的问题是textfield在一行中写入所有内容,我需要在textfield的边界处换行。 你知道如何更好地处理文本字段吗? 这是代码的一部分:Ios Can';t退出文本域颤振,ios,flutter,mobile,flutter-layout,flutter-test,Ios,Flutter,Mobile,Flutter Layout,Flutter Test,我需要一个框来插入和存储用户输入的一些信息,我正在使用“TextField”,所以我将“TextField”中的“maxLines”选项从默认值(1)更改为(2),当我想在这里插入一些文本时,我不能离开框,因为“Done”按钮更改为“return”阻止了我!键盘也被屏蔽了。 我这样做是因为我想要一个盒子,里面有一些文字(如描述),我可以移动到我想要的地方,并更改它的所有属性。 我的问题是textfield在一行中写入所有内容,我需要在textfield的边界处换行。 你知道如何更好地处理文本字段
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.white,
body : Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
image: DecorationImage(
image: _image == null
? AssetImage('assets/images/io.png')
: FileImage(_image), // here add your image file path,
alignment: Alignment.topCenter,
),
),
child: GestureDetector(
child:Container(
alignment: Alignment.center,
child : ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 400,
maxWidth: 400,
),
child: TextField(
minLines: 1,
maxLines: 2,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
const Radius.circular(48.0)
),
),
labelText: 'Descrizione',
labelStyle: TextStyle(
backgroundColor: Colors.white,
),
),
),
),
),
)
)
);
注意:我正在研究这个“手势检测器”,我想它应该对这个目的有用。在
文本字段中进入输入装饰
并向后缀属性添加一个小部件。后缀属性是一个小部件,显示在Textfield
的末尾
FocusNode node = FocusNode();
TextField(
minLines: 1,
maxLines: 2,
focusNode: node,
decoration: InputDecoration(
suffix: RaisedButton(
onPressed: () {
node.unfocus();
},
child: Text("Done"),
),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(const Radius.circular(48.0)),
),
labelText: 'Descrizione',
labelStyle: TextStyle(
backgroundColor: Colors.white,
),
),
),
在文本字段中
进入输入装饰
并向后缀属性添加小部件。后缀属性是一个小部件,显示在Textfield
的末尾
FocusNode node = FocusNode();
TextField(
minLines: 1,
maxLines: 2,
focusNode: node,
decoration: InputDecoration(
suffix: RaisedButton(
onPressed: () {
node.unfocus();
},
child: Text("Done"),
),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(const Radius.circular(48.0)),
),
labelText: 'Descrizione',
labelStyle: TextStyle(
backgroundColor: Colors.white,
),
),
),