Skip to content

Conversation

@ahmedsameha1
Copy link
Contributor

This is my attempt to handle #6537 for the FocusScope widget.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: focus Focus traversal, gaining or losing focus labels Jan 9, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a regression test for an issue where FocusScope would crash in a zero-sized environment. The new test case correctly sets up this scenario to prevent future regressions. My feedback focuses on improving the test's teardown logic to ensure better test isolation.

Comment on lines +1086 to +1089
tester.view.physicalSize = Size.zero;
final focusScopeNode = FocusScopeNode();
addTearDown(tester.view.reset);
addTearDown(focusScopeNode.dispose);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To ensure test isolation, it's better to restore the original physicalSize of the view in a teardown block rather than calling tester.view.reset(). This prevents side effects on other tests that might rely on a default view size. The suggested change saves the original size and restores it after the test, ensuring a clean state for subsequent tests.

Suggested change
tester.view.physicalSize = Size.zero;
final focusScopeNode = FocusScopeNode();
addTearDown(tester.view.reset);
addTearDown(focusScopeNode.dispose);
final Size originalSize = tester.view.physicalSize;
addTearDown(() => tester.view.physicalSize = originalSize);
tester.view.physicalSize = Size.zero;
final focusScopeNode = FocusScopeNode();
addTearDown(focusScopeNode.dispose);

Copy link
Contributor

@victorsanni victorsanni left a comment

Choose a reason for hiding this comment

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

Does FocusScope have its own renderbox? I took a look at the source code and it just wraps its child in an InheritedNotifier + Semantics. cc @dkwingsmt

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM. I think it's fine. It's to guarantee that we don't make any significant changes that involve layout in the future.

@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 13, 2026
@auto-submit auto-submit bot added this pull request to the merge queue Jan 13, 2026
Merged via the queue into flutter:master with commit 48c2475 Jan 13, 2026
70 of 71 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 13, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 14, 2026
ikramhasan pushed a commit to ikramhasan/flutter that referenced this pull request Jan 15, 2026
tarrinneal pushed a commit to flutter/packages that referenced this pull request Jan 16, 2026
Manual roll requested by tarrinneal@google.com

flutter/flutter@b45a73b...5a2067b

2026-01-13 engine-flutter-autoroll@skia.org Roll Packages from
e57e7f4 to eb9e1dc (6 revisions) (flutter/flutter#180907)
2026-01-13 ahmedsameha1@gmail.com Make sure that a FocusScope doesn't
crash in 0x0 environment (flutter/flutter#180715)
2026-01-13 bkonyi@google.com [ Tool ] Handle
`DartDevelopmentServiceException` when launching web applications
(flutter/flutter#180905)
2026-01-13 116356835+AbdeMohlbi@users.noreply.github.com Removes
`RequiresApi 23` (flutter/flutter#180629)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to
ensure that a human
is aware of the problem.

To file a bug in Packages:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 16, 2026
Manual roll requested by tarrinneal@google.com

flutter/flutter@b45a73b...48c2475

2026-01-13 ahmedsameha1@gmail.com Make sure that a FocusScope doesn't crash in 0x0 environment (flutter/flutter#180715)
2026-01-13 bkonyi@google.com [ Tool ] Handle `DartDevelopmentServiceException` when launching web applications (flutter/flutter#180905)
2026-01-13 116356835+AbdeMohlbi@users.noreply.github.com Removes `RequiresApi 23` (flutter/flutter#180629)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: focus Focus traversal, gaining or losing focus framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants