[Widget Inspector] Only include truncated field in JSON response if true (#159701)

Work towards https://github.com/flutter/devtools/issues/8582

Follow up to https://github.com/flutter/flutter/pull/159454

Only include the `truncated` field if it is `true`. We accidentally were
including it even when `false` which is what caused the regression in
the DevTools tests.
This commit is contained in:
Elliott Brooks 2024-12-03 13:16:20 -08:00 committed by GitHub
parent 1b048b0219
commit 8106f2ad1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -1892,7 +1892,8 @@ abstract class DiagnosticsNode {
// description instead, see:
// https://github.com/flutter/devtools/issues/8556
'widgetRuntimeType': widgetRuntimeType,
'truncated': truncated,
if (truncated)
'truncated': truncated,
...delegate.additionalNodeProperties(this, fullDetails: false),
if (includeChildren) 'children': childrenJsonList,
};

View File

@ -130,6 +130,12 @@ void main() {
reason: '$keyName is not included.',
);
}
// The truncated value should not be included if it is false.
expect(
result['truncated'] == null || result['truncated'] == true,
isTrue,
);
});
test('subtreeDepth 1', () {