Skip to content

Commit cc99d58

Browse files
authored
Fix sizing issues (#529)
1 parent d270754 commit cc99d58

3 files changed

Lines changed: 27 additions & 18 deletions

File tree

third_party/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGES
22

3+
## 0.21.0-nullsafety.1
4+
5+
- Fix bug introduced when width and height are both null on the widget.
6+
- Use more efficient method for XML attribute parsing.
7+
38
## 0.21.0-nullsafety.0
49

510
- Fix sizing when both width and height are null. This is potentially breaking.

third_party/lib/svg.dart

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -766,26 +766,30 @@ class _SvgPictureState extends State<SvgPicture> {
766766
height = width / viewport.width * viewport.height;
767767
}
768768

769-
child = FittedBox(
770-
fit: widget.fit,
771-
alignment: widget.alignment,
772-
clipBehavior: widget.clipBehavior,
773-
child: SizedBox.fromSize(
774-
size: viewport.size,
775-
child: RawPicture(
776-
_picture,
777-
matchTextDirection: widget.matchTextDirection,
778-
allowDrawingOutsideViewBox: widget.allowDrawingOutsideViewBox,
769+
if (height == null && width == null) {
770+
height = viewport.height;
771+
width = viewport.width;
772+
}
773+
assert(height != null);
774+
assert(width != null);
775+
776+
child = SizedBox(
777+
width: width,
778+
height: height,
779+
child: FittedBox(
780+
fit: widget.fit,
781+
alignment: widget.alignment,
782+
clipBehavior: widget.clipBehavior,
783+
child: SizedBox.fromSize(
784+
size: viewport.size,
785+
child: RawPicture(
786+
_picture,
787+
matchTextDirection: widget.matchTextDirection,
788+
allowDrawingOutsideViewBox: widget.allowDrawingOutsideViewBox,
789+
),
779790
),
780791
),
781792
);
782-
if (width != null && height != null) {
783-
child = SizedBox(
784-
width: width,
785-
height: height,
786-
child: child,
787-
);
788-
}
789793

790794
if (widget.pictureProvider.colorFilter == null &&
791795
widget.colorFilter != null) {

third_party/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: flutter_svg
22
description: An SVG rendering and widget library for Flutter, which allows painting and displaying Scalable Vector Graphics 1.1 files.
33
homepage: https://github.com/dnfield/flutter_svg
4-
version: 0.21.0-nullsafety.0
4+
version: 0.21.0-nullsafety.1
55

66
dependencies:
77
flutter:

0 commit comments

Comments
 (0)