Skip to content

Commit b391dd4

Browse files
committed
Merge branch 'warmth_fix'
2 parents 1e9b22e + 9ec074b commit b391dd4

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

flare_flutter/lib/flare_cache_builder.dart

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@ class FlareCacheBuilder extends StatefulWidget {
1717
}
1818

1919
class _FlareCacheBuilderState extends State<FlareCacheBuilder> {
20-
bool isWarm = false;
20+
bool _isWarm = false;
21+
bool get isWarm => _isWarm;
22+
set isWarm(bool value) {
23+
if (value == _isWarm) {
24+
return;
25+
}
26+
if (mounted) {
27+
setState(() {
28+
_isWarm = value;
29+
});
30+
}
31+
}
32+
2133
final Set<FlareCacheAsset> _assets = {};
2234
@override
2335
void initState() {
@@ -62,24 +74,21 @@ class _FlareCacheBuilderState extends State<FlareCacheBuilder> {
6274
}
6375

6476
bool _updateWarmth() {
77+
if (!mounted) {
78+
return true;
79+
}
6580
var filenames = widget.filenames;
6681
if (filenames == null) {
67-
setState(() {
68-
isWarm = true;
69-
});
82+
isWarm = true;
7083
return true;
7184
}
7285
for (final filename in filenames) {
7386
if (getWarmActor(bundle, filename) == null) {
74-
setState(() {
75-
isWarm = false;
76-
});
87+
isWarm = false;
7788
return false;
7889
}
7990
}
80-
setState(() {
81-
isWarm = true;
82-
});
91+
isWarm = true;
8392
return true;
8493
}
8594

0 commit comments

Comments
 (0)