Skip to content

When the Form widget calls the reset method, if it contains widget of the FormField type (such as TextFormField), the onChange method of those components will not be called #123009

@yeleibo

Description

@yeleibo
class TestWidget extends StatelessWidget {
  final _formKey = GlobalKey<FormState>();
  TestWidget({Key? key}) : super(key: key);
  
  @override
  Widget build(BuildContext context) {
    return Form(
      key: _formKey,
      child: Column(
        children: [
          ElevatedButton(
            onPressed: (){
              _formKey.currentState?.reset();
            },
            child: const Text("reset")
          ),
          TextFormField(
            onChanged: (value) {
              // not executed on _formKey.currentState?.reset()
              print(value);
            }
          )
        ],
      )
    );
  }
}

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.found in release: 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9frameworkflutter/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

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions