Skip to content

Commit

Permalink
Introducing FlareTesting.setup();
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-rosso committed Oct 5, 2019
1 parent 2c5f420 commit 4d06431
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
4 changes: 4 additions & 0 deletions flare_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.5.12] - 2019-10-04 17:56:54

- Introduce FlareTesting.setup(); call this prior to running any tests using Flare content.

## [1.5.11] - 2019-10-04 13:44:04

- Clamping trim start/end values to 0-1.
Expand Down
31 changes: 22 additions & 9 deletions flare_flutter/lib/flare_cache_asset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,34 @@ class FlareCacheAsset extends CacheAsset {
FlutterActor _actor;
FlutterActor get actor => _actor;

static bool useCompute = true;

void loadedActor(FlutterActor actor, String filename) {
actor.loadImages().then((_) {
if (actor != null) {
_actor = actor;
completeLoad();
} else {
print("Failed to load flare file from $filename.");
}
});
}

@override
void load(Cache cache, String filename) {
super.load(cache, filename);
if (cache is AssetBundleCache) {
cache.bundle.load(filename).then((ByteData data) {
compute(FlutterActor.loadFromByteData, data).then((FlutterActor actor) {
actor.loadImages().then((_) {
if (actor != null) {
_actor = actor;
completeLoad();
} else {
print("Failed to load flare file from $filename.");
}
if (useCompute) {
compute(FlutterActor.loadFromByteData, data)
.then((FlutterActor actor) {
loadedActor(actor, filename);
});
} else {
FlutterActor.loadFromByteData(data).then((FlutterActor actor) {
loadedActor(actor, filename);
});
});
}
});
}
}
Expand Down
9 changes: 9 additions & 0 deletions flare_flutter/lib/flare_testing.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'flare_cache.dart';
import 'flare_cache_asset.dart';

class FlareTesting {
static void setup() {
FlareCache.doesPrune = false;
FlareCacheAsset.useCompute = false;
}
}
2 changes: 1 addition & 1 deletion flare_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flare_flutter
description: Vector design and runtime animation for Flutter.
version: 1.5.11
version: 1.5.12
author: "2Dimensions Team <info@2dimensions.com>"
homepage: https://github.com/2d-inc/Flare-Flutter
environment:
Expand Down

0 comments on commit 4d06431

Please sign in to comment.