Skip to content

Commit 01dadbc

Browse files
authored
Fix type-cast error when deserializing a widget's size (flutter#8343)
1 parent 4665e39 commit 01dadbc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/devtools_app/lib/src/screens/inspector_v2/inspector_data_models.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class LayoutProperties {
127127
children = copyLevel == 0
128128
? []
129129
: node.childrenNow
130+
.where((child) => child.size != null)
130131
.map(
131132
(child) => LayoutProperties(child, copyLevel: copyLevel - 1),
132133
)

packages/devtools_app/lib/src/shared/diagnostics/diagnostics_node.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@ class RemoteDiagnosticsNode extends DiagnosticableTree {
7575
);
7676
}
7777

78-
static Size deserializeSize(Map<String, Object> json) {
78+
static Size? deserializeSize(Map<String, Object> json) {
79+
final width = json['width'] as String?;
80+
final height = json['height'] as String?;
81+
if (width == null || height == null) return null;
7982
return Size(
80-
double.parse(json['width'] as String),
81-
double.parse(json['height'] as String),
83+
double.parse(width),
84+
double.parse(height),
8285
);
8386
}
8487

@@ -461,6 +464,7 @@ class RemoteDiagnosticsNode extends DiagnosticableTree {
461464
if ((!forFlexLayout && !isBoxLayout) || (forFlexLayout && !isFlexLayout)) {
462465
return null;
463466
}
467+
if (size == null) return null;
464468
return forFlexLayout
465469
? FlexLayoutProperties.fromDiagnostics(this)
466470
: LayoutProperties(this);

0 commit comments

Comments
 (0)