Skip to content

Commit

Permalink
Insert null checks for artboards with no drawables #178
Browse files Browse the repository at this point in the history
  • Loading branch information
umberto-sonnino committed Oct 25, 2019
1 parent 33f23a7 commit 528af53
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
26 changes: 18 additions & 8 deletions flare_dart/lib/actor_artboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,20 @@ class ActorArtboard {
Float32List get overrideColor => _overrideColor;

set overrideColor(Float32List value) {
_overrideColor = value;
for (final ActorDrawable drawable in _drawableNodes) {
addDirt(drawable, DirtyFlags.paintDirty, true);
if (_drawableNodes != null) {
_overrideColor = value;
for (final ActorDrawable drawable in _drawableNodes) {
addDirt(drawable, DirtyFlags.paintDirty, true);
}
}
}

set modulateOpacity(double value) {
_modulateOpacity = value;
for (final ActorDrawable drawable in _drawableNodes) {
addDirt(drawable, DirtyFlags.paintDirty, true);
if (_drawableNodes != null) {
_modulateOpacity = value;

This comment has been minimized.

Copy link
@luigi-rosso

luigi-rosso Oct 25, 2019

Contributor

I'd probably still set _modulateOpacity even if the _drawableNodes is null!

for (final ActorDrawable drawable in _drawableNodes) {
addDirt(drawable, DirtyFlags.paintDirty, true);
}
}
}

Expand Down Expand Up @@ -570,8 +574,10 @@ class ActorArtboard {
}

void initializeGraphics() {
for (final ActorDrawable drawable in _drawableNodes) {
drawable.initializeGraphics();
if (_drawableNodes != null) {
for (final ActorDrawable drawable in _drawableNodes) {
drawable.initializeGraphics();
}
}
}

Expand Down Expand Up @@ -600,6 +606,10 @@ class ActorArtboard {
}

AABB computeAABB() {
if (_drawableNodes == null) {
return AABB();
}

AABB aabb;
for (final ActorDrawable drawable in _drawableNodes) {
// This is the axis aligned bounding box in the space
Expand Down
3 changes: 3 additions & 0 deletions flare_flutter/lib/flare.dart
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@ class FlutterActorArtboard extends ActorArtboard {
FlutterActorArtboard(FlutterActor actor) : super(actor);

void draw(ui.Canvas canvas) {
if (drawableNodes == null || drawableNodes.isEmpty) {
return;
}
if (clipContents) {
canvas.save();
AABB aabb = artboardAABB();
Expand Down

0 comments on commit 528af53

Please sign in to comment.