Repository navigation
Don't show an expand arrow next to String variables - #10100
Open
Abhilash-Puthukkudi wants to merge 2 commits into
Open
Abhilash-Puthukkudi wants to merge 2 commits into
Abhilash-Puthukkudi wants to merge 2 commits into
Conversation
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
requested review from
srawlins
and removed request for
a team
November 29, 2026 15:33
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.lengthfor Strings to the number of code units (see thelengthdocs inpackage:vm_service).DartObjectNode.childCountreturns that length, soDartObjectNode.isExpandablecounted every non-empty String as a node with children.Fix:
isExpandablenow ignoreschildCountforInstanceKind.kStringinstances.childCountitself is unchanged becauseisPartialObjectandgetObject()rely on it. Changing it would make Strings look like partial objects and request them withcount: 0. Strings that are heap selections still show thereferenceschild, becauseisRootForReferencesis checked first.Tests:
buildStringVariablenever setlength, unlike a live VM, which is why the existingstringstest didn't catch this. It now takes an optionallengthparameter.isExpandabletests indart_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.Pre-launch Checklist
General checklist
///).Issues checklist
contributions-welcomeorgood-first-issuelabel.contributions-welcomeorgood-first-issuelabel. I understand this means my PR might take longer to be reviewed.Tests checklist
AI-tooling checklist
Feature-change checklist
release-notes-not-requiredlabel or left a comment requesting the label be added.packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.If you need help, consider asking for help on Discord.