Skip to content

TextField hint is ellided at one line with maxLines: null #46182

@justinmc

Description

@justinmc

Most multiline TextFields expand to accommodate their hint, except when maxLines is null. Instead, it should accommodate the hint when maxLines is null as well. This would reduce confusion and allow a TextField that grows to any size to accommodate the hint, which is currently not possible.

Correct Case

Setting maxLines allows the TextField to increase in size to fit as much of the hint as possible:

TextField(
  minLines: null,
  maxLines: 2,
  decoration: InputDecoration(
    hintText: 'To be, or not to be, that is the question. Whether \'tis nobler in the mind to suffer the slings and arrows of outrageous fortune, or to take arm against a sea of trouble, and by opposing, end them.',
  ),
)

flutter_29

Incorrect Case

However, when maxLines is null, the TextField stays at 1 line regardless of the length of the hint:

TextField(
  minLines: null,
  maxLines: null,
  decoration: InputDecoration(
    hintText: 'To be, or not to be, that is the question. Whether \'tis nobler in the mind to suffer the slings and arrows of outrageous fortune, or to take arm against a sea of trouble, and by opposing, end them.',
  ),
)

flutter_30

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsc: API breakBackwards-incompatible API changesf: material designflutter/packages/flutter/material repository.found in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions