Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into…
Browse files Browse the repository at this point in the history
… dev
  • Loading branch information
luigi-rosso committed Apr 26, 2019
2 parents 2ec15af + 4416a67 commit 113d791
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion flare_flutter/lib/flare_actor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ class FlareActorRenderObject extends FlareRenderBox {

@override
void load() {
if (_filename == null) {
return;
}
super.load();
loadFlare(_filename).then((FlutterActor actor) {
if (actor == null || actor.artboard == null) {
Expand Down Expand Up @@ -302,7 +305,8 @@ class FlareActorRenderObject extends FlareRenderBox {
}
}

if (_artboard != null && _controller != null &&
if (_artboard != null &&
_controller != null &&
!_controller.advance(_artboard, elapsedSeconds)) {
_controller?.isActive?.value = false;
}
Expand Down
19 changes: 15 additions & 4 deletions flare_flutter/lib/flare_render_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class FlareRenderBox extends RenderBox {
}
_assetBundle = value;
if (_assetBundle != null) {
load();
_load();
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ abstract class FlareRenderBox extends RenderBox {
super.attach(owner);
updatePlayState();
if (_assets.isEmpty && assetBundle != null) {
load();
_load();
}
}

Expand Down Expand Up @@ -202,11 +202,22 @@ abstract class FlareRenderBox extends RenderBox {
/// Advance animations, physics, etc by elapsedSeconds.
void advance(double elapsedSeconds);

/// Perform any loading logic necessary for this scene.
void load() {
bool _isLoading = false;
bool get isLoading => _isLoading;

void _load() async {
if (_isLoading) {
return;
}
_isLoading = true;
_unload();
await load();
_isLoading = false;
}

/// Perform any loading logic necessary for this scene.
void load() async {}

void _unload() {
for (final FlareCacheAsset asset in _assets) {
asset.deref();
Expand Down

0 comments on commit 113d791

Please sign in to comment.