0

I'm trying to get the placeholder text in a CupertinoTextField to wrap to the next line, rather than being cut off with an ellipsis.

When I set maxLines to a value (e.g. 5), the placeholder text wraps. However, I want the TextField to expand with the user's input, so I need to set maxLines to null.

    return CupertinoTextField(
      controller: _textController,
      autofocus: true,
      placeholder:
          "This is a very long placeholder text that should wrap to the next line.",
      maxLines: null,
    );

Is there a workaround to get the placeholder text to wrap?

sia
  • 256
  • 3
  • 14
  • How did you go with this, was there a solution? – Waylan Sands Jun 30 '22 at 04:16
  • I ended up finding the line in Flutter's implementation of CupertinoTextField where overflow: TextOverflow.ellipsis is set. Removing that overflow line caused the text to wrap as desired. – sia Jun 30 '22 at 21:53

1 Answers1

1

My solution was to set minLines: 2, and set maxLines: (greater than 2) make sure expands is set to false or excluded.

Waylan Sands
  • 321
  • 3
  • 11