Skip to content

Commit

Permalink
Fix type-cast error when deserializing a widget's size (flutter#8343)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Sep 25, 2024
1 parent 4665e39 commit 01dadbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class LayoutProperties {
children = copyLevel == 0
? []
: node.childrenNow
.where((child) => child.size != null)
.map(
(child) => LayoutProperties(child, copyLevel: copyLevel - 1),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ class RemoteDiagnosticsNode extends DiagnosticableTree {
);
}

static Size deserializeSize(Map<String, Object> json) {
static Size? deserializeSize(Map<String, Object> json) {
final width = json['width'] as String?;
final height = json['height'] as String?;
if (width == null || height == null) return null;
return Size(
double.parse(json['width'] as String),
double.parse(json['height'] as String),
double.parse(width),
double.parse(height),
);
}

Expand Down Expand Up @@ -461,6 +464,7 @@ class RemoteDiagnosticsNode extends DiagnosticableTree {
if ((!forFlexLayout && !isBoxLayout) || (forFlexLayout && !isFlexLayout)) {
return null;
}
if (size == null) return null;
return forFlexLayout
? FlexLayoutProperties.fromDiagnostics(this)
: LayoutProperties(this);
Expand Down

0 comments on commit 01dadbc

Please sign in to comment.