[flutter] Fixes #2546, fix drawing before controller initialized drawable

This commit is contained in:
Mario Zechner 2024-06-11 14:07:50 +02:00
parent ac4ff96915
commit c0efb545bd
5 changed files with 17 additions and 6 deletions

View File

@ -1,3 +1,6 @@
# 4.2.27
- Fixes clipping in case of colinear clipping edges.
# 4.2.26
- `Skeleton.getBounds()` takes clipping into consideration.

View File

@ -37,8 +37,12 @@ class SimpleAnimation extends StatelessWidget {
Widget build(BuildContext context) {
reportLeaks();
final controller = SpineWidgetController(onInitialized: (controller) {
// Set the walk animation on track 0, let it loop
controller.animationState.setAnimationByName(0, "walk", true);
// Set the default mixing time between animations
controller.animationState.getData().setDefaultMix(0.2);
// Set the portal animation on track 0
controller.animationState.setAnimationByName(0, "portal", true);
// Queue the run animation after the portal animation
controller.animationState.addAnimationByName(0, "run", true, 0);
});
return Scaffold(

View File

@ -483,6 +483,7 @@ class _SpineRenderObject extends RenderBox {
Bounds _bounds;
bool _sizedByBounds;
bool _disposed = false;
bool _firstUpdated = false;
_SpineRenderObject(this._skeletonDrawable, this._controller, this._fit, this._alignment, this._bounds, this._sizedByBounds);
@ -618,6 +619,7 @@ class _SpineRenderObject extends RenderBox {
markNeedsPaint();
_scheduleFrame();
}
_firstUpdated = true;
}
void _setCanvasTransform(Canvas canvas, Offset offset) {
@ -669,9 +671,11 @@ class _SpineRenderObject extends RenderBox {
canvas.save();
_setCanvasTransform(canvas, offset);
_controller.onBeforePaint?.call(_controller, canvas);
final commands = _skeletonDrawable.renderToCanvas(canvas);
_controller.onAfterPaint?.call(_controller, canvas, commands);
if (_firstUpdated) {
_controller.onBeforePaint?.call(_controller, canvas);
final commands = _skeletonDrawable.renderToCanvas(canvas);
_controller.onAfterPaint?.call(_controller, canvas, commands);
}
canvas.restore();
}

View File

@ -1,6 +1,6 @@
name: spine_flutter
description: The official Spine Flutter Runtime to load, display and interact with Spine animations.
version: 4.2.26
version: 4.2.27
homepage: https://esotericsoftware.com
repository: https://github.com/esotericsoftware/spine-runtimes
issue_tracker: https://github.com/esotericsoftware/spine-runtimes/issues