0
votes

I need to update the value ListTile inside a card. So onLongPress(), I use showDialog to show a textfield. The initial value of the textfield is updated in initState().

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

Here is my showdialog:

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);
              },
            ),
          ],
        );
      },
    );

Here is the produced showdialog:

enter image description here

1
Looks like this is because you've used maxLines: 100. If you don't set maxLines then there's no limit. If you need to enforce a limit, you can use maxLength instead. - Derek Lakin

1 Answers

1
votes

Use maxLines: null to make the TextField multi-line with auto warping.