Merge pull request #48 from rive-app/fix_intrinsic_size

Support for intrinsic size
This commit is contained in:
Matt Sullivan
2021-01-23 15:49:23 -08:00
committed by GitHub
4 changed files with 19 additions and 2 deletions

View File

@ -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 ## [0.6.6+1] - 2021-01-18 17:06:17
- Fixes a crashing issue introduced in 0.6.6. - Fixes a crashing issue introduced in 0.6.6.

View File

@ -24,6 +24,8 @@ class Rive extends LeafRenderObjectWidget {
..artboard = artboard ..artboard = artboard
..fit = fit ..fit = fit
..alignment = alignment ..alignment = alignment
..intrinsicSize =
artboard == null ? Size.zero : Size(artboard.width, artboard.height)
..useIntrinsicSize = useIntrinsicSize; ..useIntrinsicSize = useIntrinsicSize;
} }
@ -34,6 +36,8 @@ class Rive extends LeafRenderObjectWidget {
..artboard = artboard ..artboard = artboard
..fit = fit ..fit = fit
..alignment = alignment ..alignment = alignment
..intrinsicSize =
artboard == null ? Size.zero : Size(artboard.width, artboard.height)
..useIntrinsicSize = useIntrinsicSize; ..useIntrinsicSize = useIntrinsicSize;
} }

View File

@ -12,6 +12,12 @@ abstract class RiveRenderBox extends RenderBox {
Alignment _alignment; Alignment _alignment;
bool _useIntrinsicSize = false; bool _useIntrinsicSize = false;
@override
Size computeDryLayout(BoxConstraints constraints) {
return constraints
.constrainSizeAndAttemptToPreserveAspectRatio(_intrinsicSize);
}
bool get useIntrinsicSize => _useIntrinsicSize; bool get useIntrinsicSize => _useIntrinsicSize;
set useIntrinsicSize(bool value) { set useIntrinsicSize(bool value) {
if (_useIntrinsicSize == value) { if (_useIntrinsicSize == value) {
@ -66,7 +72,10 @@ abstract class RiveRenderBox extends RenderBox {
@override @override
void performResize() { void performResize() {
size = _useIntrinsicSize ? constraints.smallest : constraints.biggest; if (_useIntrinsicSize) {
super.performResize();
}
size = constraints.biggest;
} }
@override @override

View File

@ -1,6 +1,6 @@
name: rive 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. 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 repository: https://github.com/rive-app/rive-flutter
homepage: https://rive.app homepage: https://rive.app