Skip to content

Commit 4d06431

Browse files
committed
Introducing FlareTesting.setup();
1 parent 2c5f420 commit 4d06431

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

flare_flutter/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.5.12] - 2019-10-04 17:56:54
2+
3+
- Introduce FlareTesting.setup(); call this prior to running any tests using Flare content.
4+
15
## [1.5.11] - 2019-10-04 13:44:04
26

37
- Clamping trim start/end values to 0-1.

flare_flutter/lib/flare_cache_asset.dart

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,34 @@ class FlareCacheAsset extends CacheAsset {
1111
FlutterActor _actor;
1212
FlutterActor get actor => _actor;
1313

14+
static bool useCompute = true;
15+
16+
void loadedActor(FlutterActor actor, String filename) {
17+
actor.loadImages().then((_) {
18+
if (actor != null) {
19+
_actor = actor;
20+
completeLoad();
21+
} else {
22+
print("Failed to load flare file from $filename.");
23+
}
24+
});
25+
}
26+
1427
@override
1528
void load(Cache cache, String filename) {
1629
super.load(cache, filename);
1730
if (cache is AssetBundleCache) {
1831
cache.bundle.load(filename).then((ByteData data) {
19-
compute(FlutterActor.loadFromByteData, data).then((FlutterActor actor) {
20-
actor.loadImages().then((_) {
21-
if (actor != null) {
22-
_actor = actor;
23-
completeLoad();
24-
} else {
25-
print("Failed to load flare file from $filename.");
26-
}
32+
if (useCompute) {
33+
compute(FlutterActor.loadFromByteData, data)
34+
.then((FlutterActor actor) {
35+
loadedActor(actor, filename);
36+
});
37+
} else {
38+
FlutterActor.loadFromByteData(data).then((FlutterActor actor) {
39+
loadedActor(actor, filename);
2740
});
28-
});
41+
}
2942
});
3043
}
3144
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import 'flare_cache.dart';
2+
import 'flare_cache_asset.dart';
3+
4+
class FlareTesting {
5+
static void setup() {
6+
FlareCache.doesPrune = false;
7+
FlareCacheAsset.useCompute = false;
8+
}
9+
}

flare_flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flare_flutter
22
description: Vector design and runtime animation for Flutter.
3-
version: 1.5.11
3+
version: 1.5.12
44
author: "2Dimensions Team <info@2dimensions.com>"
55
homepage: https://github.com/2d-inc/Flare-Flutter
66
environment:

0 commit comments

Comments
 (0)