Skip to content

Commit

Permalink
Fix sizing issues (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield committed Apr 6, 2021
1 parent f1116b7 commit 3dca054
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGES

## 0.21.0-nullsafety.1

- Fix bug introduced when width and height are both null on the widget.
- Use more efficient method for XML attribute parsing.

## 0.21.0-nullsafety.0

- Fix sizing when both width and height are null. This is potentially breaking.
Expand Down
38 changes: 21 additions & 17 deletions lib/svg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -766,26 +766,30 @@ class _SvgPictureState extends State<SvgPicture> {
height = width / viewport.width * viewport.height;
}

child = FittedBox(
fit: widget.fit,
alignment: widget.alignment,
clipBehavior: widget.clipBehavior,
child: SizedBox.fromSize(
size: viewport.size,
child: RawPicture(
_picture,
matchTextDirection: widget.matchTextDirection,
allowDrawingOutsideViewBox: widget.allowDrawingOutsideViewBox,
if (height == null && width == null) {
height = viewport.height;
width = viewport.width;
}
assert(height != null);
assert(width != null);

child = SizedBox(
width: width,
height: height,
child: FittedBox(
fit: widget.fit,
alignment: widget.alignment,
clipBehavior: widget.clipBehavior,
child: SizedBox.fromSize(
size: viewport.size,
child: RawPicture(
_picture,
matchTextDirection: widget.matchTextDirection,
allowDrawingOutsideViewBox: widget.allowDrawingOutsideViewBox,
),
),
),
);
if (width != null && height != null) {
child = SizedBox(
width: width,
height: height,
child: child,
);
}

if (widget.pictureProvider.colorFilter == null &&
widget.colorFilter != null) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_svg
description: An SVG rendering and widget library for Flutter, which allows painting and displaying Scalable Vector Graphics 1.1 files.
homepage: https://github.com/dnfield/flutter_svg
version: 0.21.0-nullsafety.0
version: 0.21.0-nullsafety.1

dependencies:
flutter:
Expand Down

0 comments on commit 3dca054

Please sign in to comment.