Skip to content

Commit

Permalink
Addressing an issue found in #177 with FlareCacheBuilder setting stat…
Browse files Browse the repository at this point in the history
…e when widget is no longer mounted.
  • Loading branch information
luigi-rosso committed Nov 6, 2019
1 parent e1cca7c commit c66ac64
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions flare_flutter/lib/flare_cache_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ class FlareCacheBuilder extends StatefulWidget {
}

class _FlareCacheBuilderState extends State<FlareCacheBuilder> {
bool isWarm = false;
bool _isWarm = false;
bool get isWarm => _isWarm;
set isWarm(bool value) {
if (value == _isWarm) {
return;
}
setState(() {
_isWarm = value;
});
}

final Set<FlareCacheAsset> _assets = {};
@override
void initState() {
Expand Down Expand Up @@ -62,24 +72,21 @@ class _FlareCacheBuilderState extends State<FlareCacheBuilder> {
}

bool _updateWarmth() {
if (!mounted) {
return true;
}
var filenames = widget.filenames;
if (filenames == null) {
setState(() {
isWarm = true;
});
isWarm = true;
return true;
}
for (final filename in filenames) {
if (getWarmActor(bundle, filename) == null) {
setState(() {
isWarm = false;
});
isWarm = false;
return false;
}
}
setState(() {
isWarm = true;
});
isWarm = true;
return true;
}

Expand Down

0 comments on commit c66ac64

Please sign in to comment.