mirror of
https://github.com/rive-app/rive-flutter
synced 2025-07-05 21:55:58 +00:00
Fix flutter validate() problem with drawable layouts
This is a bit of an odd one related to not updating the flutter runtime since we moved to rive_native. @drawsgood and I observed that sometimes nested artboards weren't rendering properly to the stage (the nested artboard would appear as an empty node). I narrowed this down to whenever a file contained a layout with either a fill or stroke. The reason this was happening is because when we add a nested artboard, we use genRuntimeFile, which exports, then imports and validates the objects in the file. During the validation, if the file had a layout with a fill, the fill would attempt to validate, one of the conditions of which is that it's parent is a ShapePaintContainer. LayoutComponent IS a ShapePaintContainer, BUT the validate() happens against the flutter object, and since we haven't pushed updates to flutter, LayoutComponent there is NOT a ShapePaintContainer. The easiest fix for this is to just add the bits to LayoutComponent in flutter related to extending ShapePaintContainer. I think this should be ok since the added code doesn't have anything to do with rive_native and the new rendering pathway. One question I have is whether we should be continuing to validate against the flutter objects when it comes to nested artboards, now that we're using rive_native. @luigi-rosso perhaps we can discuss further when you are back in office. Diffs= c3137b923 Fix flutter validate() problem with drawable layouts (#7727) d9f5701ec add listener actions support for databind (#7710) dcb165130 Fix alignment when flex wrap enabled (#7722) fbfa3b545 Buildsystem fixes for build_rive.sh and PLS shaders (#7716) 405ca998b add click event support (#7668) 4732c37b5 Improve layout animation (#7712) a56419984 Simple procedural text rendering API (#7701) d6d79132b Add a test for nested events triggering listener in parent (#7709) 657f65e1c Fix for nested events in CPP (#7708) 0a11e599f Add a build_rive.sh script to unify the premake5 build process (#7691) d25b9097d viewmodel transitions runtime (#7680) Co-authored-by: Philip Chung <philterdesign@gmail.com>
This commit is contained in:
@ -1 +1 @@
|
||||
462725b0766c65fe6b69530e86cd0de46a8795b3
|
||||
c3137b923ca5d62771f85dcae10afcba6de083d3
|
||||
|
@ -10,6 +10,8 @@ import 'package:rive/src/rive_core/component_dirt.dart';
|
||||
import 'package:rive/src/rive_core/container_component.dart';
|
||||
import 'package:rive/src/rive_core/layout/layout_component_style.dart';
|
||||
import 'package:rive/src/rive_core/node.dart';
|
||||
import 'package:rive/src/rive_core/shapes/paint/shape_paint_mutator.dart';
|
||||
import 'package:rive/src/rive_core/shapes/shape_paint_container.dart';
|
||||
import 'package:rive/src/rive_core/world_transform_component.dart';
|
||||
import 'package:rive_common/layout_engine.dart';
|
||||
import 'package:rive_common/math.dart';
|
||||
@ -36,7 +38,7 @@ class LayoutAnimationData {
|
||||
LayoutAnimationData(this.fromBounds, this.toBounds);
|
||||
}
|
||||
|
||||
class LayoutComponent extends LayoutComponentBase {
|
||||
class LayoutComponent extends LayoutComponentBase with ShapePaintContainer {
|
||||
bool _forceUpdateLayoutBounds = false;
|
||||
|
||||
LayoutComponentStyle? _style;
|
||||
@ -139,6 +141,33 @@ class LayoutComponent extends LayoutComponentBase {
|
||||
interpolationTime > 0;
|
||||
}
|
||||
|
||||
@override
|
||||
void onPaintMutatorChanged(ShapePaintMutator mutator) {
|
||||
// The transform affects stroke property may have changed as we have a new
|
||||
// mutator.
|
||||
paintChanged();
|
||||
}
|
||||
|
||||
@override
|
||||
void onStrokesChanged() => paintChanged();
|
||||
|
||||
@override
|
||||
void onFillsChanged() => paintChanged();
|
||||
|
||||
void paintChanged() {
|
||||
addDirt(ComponentDirt.path);
|
||||
|
||||
// Add world transform dirt to the direct dependents (don't recurse) as
|
||||
// things like ClippingShape directly depend on their referenced Shape. This
|
||||
// allows them to recompute any stored values which can change when the
|
||||
// transformAffectsStroke property changes (whether the path is in world
|
||||
// space or not). Consider using a different dirt type if this pattern is
|
||||
// repeated.
|
||||
for (final d in dependents) {
|
||||
d.addDirt(ComponentDirt.worldTransform);
|
||||
}
|
||||
}
|
||||
|
||||
void markLayoutNodeDirty() {
|
||||
_layoutNode.markDirty();
|
||||
artboard?.markLayoutDirty(this);
|
||||
|
Reference in New Issue
Block a user