Flutter:文本字段的初始值会产生其他新行

时间:2018-07-30 06:52:29

标签: dart flutter textfield

我需要更新卡中的ListTile值。因此,在onLongPress()中,我使用showDialog来显示文本字段。文本字段的初始值在initState()中更新。

 @override
  void initState() {
    super.initState();
    print(widget.project['status_long']);
    projectDetailsController = TextEditingController(text: widget.project['status_long']);
  }

这是我的表演对话:

showDialog<void>(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text("Project Update"),
          content: TextField(
            controller: projectDetailsController,
            maxLines: 100,
            keyboardType: TextInputType.multiline,
          ),
          actions: <Widget>[
            FlatButton(
              child: Text("UPDATE"),
              onPressed: () {
                _updateProjectDetails("projects/" + widget.project.documentID, projectDetailsController.text);
                projectDetailsController.clear();
                Navigator.pop(context);
              },
            ),
          ],
        );
      },
    );

这是制作的showdialog:

enter image description here

1 个答案:

答案 0 :(得分:1)

使用maxLines: null通过自动变形使TextField多行。

相关问题