From 09cff9b79462724c3852c61e5d7d3832f4c27713 Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Sat, 23 Jan 2021 11:10:25 -0800 Subject: [PATCH 1/2] Adding support for intrinsic size. --- lib/src/rive.dart | 4 ++++ lib/src/rive_render_box.dart | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/src/rive.dart b/lib/src/rive.dart index 249bfeb..28beb6b 100644 --- a/lib/src/rive.dart +++ b/lib/src/rive.dart @@ -24,6 +24,8 @@ class Rive extends LeafRenderObjectWidget { ..artboard = artboard ..fit = fit ..alignment = alignment + ..intrinsicSize = + artboard == null ? Size.zero : Size(artboard.width, artboard.height) ..useIntrinsicSize = useIntrinsicSize; } @@ -34,6 +36,8 @@ class Rive extends LeafRenderObjectWidget { ..artboard = artboard ..fit = fit ..alignment = alignment + ..intrinsicSize = + artboard == null ? Size.zero : Size(artboard.width, artboard.height) ..useIntrinsicSize = useIntrinsicSize; } diff --git a/lib/src/rive_render_box.dart b/lib/src/rive_render_box.dart index 4a4e0d2..93ce25b 100644 --- a/lib/src/rive_render_box.dart +++ b/lib/src/rive_render_box.dart @@ -12,6 +12,12 @@ abstract class RiveRenderBox extends RenderBox { Alignment _alignment; bool _useIntrinsicSize = false; + @override + Size computeDryLayout(BoxConstraints constraints) { + return constraints + .constrainSizeAndAttemptToPreserveAspectRatio(_intrinsicSize); + } + bool get useIntrinsicSize => _useIntrinsicSize; set useIntrinsicSize(bool value) { if (_useIntrinsicSize == value) { @@ -66,7 +72,10 @@ abstract class RiveRenderBox extends RenderBox { @override void performResize() { - size = _useIntrinsicSize ? constraints.smallest : constraints.biggest; + if (_useIntrinsicSize) { + super.performResize(); + } + size = constraints.biggest; } @override From beac79bb669a8ab291bd02ac84b5fe3581595f94 Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Sat, 23 Jan 2021 11:13:53 -0800 Subject: [PATCH 2/2] Prepping for pub. --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0881cef..52b279b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.6.7] - 2021-01-23 11:11:02 + +- Adds support for Rive.useIntrinsicSize to allow Rive widgets to be self sized by their artboard. Set useIntrinsicSize to false when you want the widget to try to occupy the entire space provided by the parent. + ## [0.6.6+1] - 2021-01-18 17:06:17 - Fixes a crashing issue introduced in 0.6.6. diff --git a/pubspec.yaml b/pubspec.yaml index 4a7e537..63da6a7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: rive description: Rive 2 Flutter Runtime. This package provides runtime functionality for playing back and interacting with animations built with the Rive editor available at https://rive.app. -version: 0.6.6+1 +version: 0.6.7 repository: https://github.com/rive-app/rive-flutter homepage: https://rive.app