Skip to content

TextField doesn't properly create a new TextEditingController on didUpdateWidget #12153

Closed

Description

@paolosoares

In TextEditingController's didUpdateWidget method:

  @override
  void didUpdateWidget(TextField oldWidget) {
    super.didUpdateWidget(oldWidget);
    if (widget.controller == null && oldWidget.controller != null)
      _controller == new TextEditingController.fromValue(oldWidget.controller.value);
    else if (widget.controller != null && oldWidget.controller == null)
      _controller = null;
  }

When widget.controller is null and oldWidget.controller isn't, _controller gets assigned instead of copied. Specifically, this:

_controller == new TextEditingController.fromValue(oldWidget.controller.value);

should be

_controller = new TextEditingController.fromValue(oldWidget.controller.value);

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: text inputEntering text in a text field or keyboard related problems
    on Sep 18, 2017
  2. added this to the 3: Current Milestone milestone on Sep 18, 2017
  3. Hixie commented on Sep 18, 2017

    @Hixie
    Contributor

    (Filed dart-lang/sdk#30793 for a lint that would have caught this.)

    cc @xster, @cbracken

  4. self-assigned this
    on Sep 20, 2017
  5. cbracken commented on Sep 20, 2017

    @cbracken
    Member

    Thanks! Fixed by #12190.

  6. github-actions commented on Sep 4, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions