Skip to content

Don't show an expand arrow next to String variables - #10100

Open
Abhilash-Puthukkudi wants to merge 2 commits into
flutter:masterfrom
Abhilash-Puthukkudi:fix-string-variables-expandable
Open

Abhilash-Puthukkudi wants to merge 2 commits into
flutter:masterfrom
Abhilash-Puthukkudi:fix-string-variables-expandable

Conversation

@Abhilash-Puthukkudi

@Abhilash-Puthukkudi Abhilash-Puthukkudi commented Nov 29, 2026 •

Copy link
Copy Markdown

Fixes #5377

String variables in the debugger's variables tree showed an expand arrow (>), even though expanding them shows nothing.

Cause: The VM service sets InstanceRef.length for Strings to the number of code units (see the length docs in package:vm_service). DartObjectNode.childCount returns that length, so DartObjectNode.isExpandable counted every non-empty String as a node with children.

Fix: isExpandable now ignores childCount for InstanceKind.kString instances. childCount itself is unchanged because isPartialObject and getObject() rely on it. Changing it would make Strings look like partial objects and request them with count: 0. Strings that are heap selections still show the references child, because isRootForReferences is checked first.

Tests:

  • The test helper buildStringVariable never set length, unlike a live VM, which is why the existing strings test didn't catch this. It now takes an optional length parameter.
  • Added isExpandable tests in dart_object_node_test.dart. They cover Strings with and without a length, Strings after their tree is initialized, booleans, and non-empty lists and maps.
  • Both new String-with-length tests fail without the fix and pass with it.

Pre-launch Checklist

General checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I updated/added relevant documentation (doc comments with ///).

Issues checklist

Tests checklist

  • I added new tests to check the change I am making...
  • OR there is a reason for not adding tests, which I explained in the PR description.

AI-tooling checklist

  • I did not use any AI tooling in creating this PR.
  • OR I did use AI tooling, and...
    • I read the AI contributions guidelines and agree to follow them.
    • I reviewed all AI-generated code before opening this PR.
    • I understand and am able to discuss the code in this PR.
    • I have verifed the accuracy of any AI-generated text included in the PR description.
    • I commit to verifying the accuracy of any AI-generated code or text that I upload in response to review comments.

Feature-change checklist

  • This PR does not change the DevTools UI or behavior and...
    • I added the release-notes-not-required label or left a comment requesting the label be added.
  • OR this PR does change the DevTools UI or behavior and...
    • I added an entry to packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.
    • I included before/after screenshots and/or a GIF demo of the new UI to my PR description.
    • I ran the DevTools app locally to manually verify my changes.

build.yaml badge

If you need help, consider asking for help on Discord.

The VM service reports the number of code units of a String as the
`InstanceRef.length`. `DartObjectNode.childCount` returns that length,
so `isExpandable` treated every non-empty String as having children and
showed a `>` next to String fields in the debugger variables tree, even
though expanding them shows nothing.

Ignore `childCount` for String instances when deciding whether a node is
expandable. `childCount` itself is unchanged, since `isPartialObject` and
`getObject` rely on it.

Fixes flutter#5377
@Abhilash-Puthukkudi
Abhilash-Puthukkudi requested a review from a team as a code owner November 29, 2026 15:33
@Abhilash-Puthukkudi
Abhilash-Puthukkudi requested review from srawlins and removed request for a team November 29, 2026 15:33

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request fixes an issue where String variables incorrectly displayed an expand arrow in the debugger's variables tree. Since the VM service reports the number of code units as the instance length for Strings, a non-zero child count was previously misinterpreted as having expandable child nodes. The fix ensures that String instances are not treated as expandable. Additionally, the PR adds comprehensive unit tests for the isExpandable property and updates the release notes. I have no feedback to provide as the changes are well-implemented and include appropriate tests.

This branch has not been deployed

No deployments
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.

> is shown next to non-expandable fields

1 participant