Skip to content

Commit ec94145

Browse files
committed
fix: aspect_ratio_NaN
1 parent d13ca75 commit ec94145

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/custom_render.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,23 @@ double? _width(Map<String, String> attributes) {
532532

533533
double _aspectRatio(
534534
Map<String, String> attributes, AsyncSnapshot<Size> calculated) {
535+
double aspectRatio;
535536
final heightString = attributes["height"];
536537
final widthString = attributes["width"];
537538
if (heightString != null && widthString != null) {
538539
final height = double.tryParse(heightString);
539540
final width = double.tryParse(widthString);
540-
return height == null || width == null
541+
aspectRatio = height == null || width == null
541542
? calculated.data!.aspectRatio
542543
: width / height;
544+
} else {
545+
aspectRatio = calculated.data!.aspectRatio;
546+
}
547+
if (!aspectRatio.isNaN) {
548+
return aspectRatio;
549+
} else {
550+
return 1;
543551
}
544-
return calculated.data!.aspectRatio;
545552
}
546553

547554
extension ClampedEdgeInsets on EdgeInsetsGeometry {

0 commit comments

Comments
 (0)