Skip to content

Converted GuessInput to a StatefulWidget in Stateful widgets tutorial - #13653

Draft
MuthuGCodes wants to merge 5 commits into
flutter:mainfrom
MuthuGCodes:mg-GuessInput-issue
Draft

Converted GuessInput to a StatefulWidget in Stateful widgets tutorial#13653
MuthuGCodes wants to merge 5 commits into
flutter:mainfrom
MuthuGCodes:mg-GuessInput-issue

Conversation

@MuthuGCodes

@MuthuGCodes MuthuGCodes commented Jul 31, 2026

Copy link
Copy Markdown

Rebuilding GamePage (after converting it to StatefulWidget) recreates GuessInput (which is currently a StatelessWidget), resetting its internal FocusNode and TextEditingController and breaking focus behavior. The fix is to convert GuessInput to a StatefulWidget in the "Stateful widgets" tutorial step and the example code.

Fixes #13392

@flutter-website-bot

flutter-website-bot commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Staged preview of the updated docs.flutter.dev site (updated for commit 9e52d59):

https://flutter-docs-prod--docs-pr13653-mg-guessinput-issue-3th19sc7.web.app

@flutter-website-bot

flutter-website-bot commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Staged preview of the updated flutter.dev site (updated for commit 9e52d59):

https://flutter-dev-230821--www-pr13653-mg-guessinput-issue-hk3zmet1.web.app

@lamek lamek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things to fix.

Comment thread workspace.code-workspace Outdated
@@ -0,0 +1,8 @@
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is local to your IDE. You can remove it.

1. Implement `dispose()` to clean up `_textEditingController` and `_focusNode`.

Your modified `GuessInput` widget should look like this:

@lamek lamek Aug 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code excerpts in the tutorial we follow these steps:

  1. Write the updated code into the corresponding /examples/FWE/lib file.
  2. Add a tag like the following: <?code-excerpt "fwe/birdle/lib/step5_main.dart (GuessInput)"?>
  3. Run the following command: dart run dash_site --site=docs refresh-excerpts

Following this flow will ensure the code snippets in our .MD files are always up to date with what is in the /examples dir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GuessInput class should be a StatelfulWidget

3 participants