Skip to content

Commit

Permalink
🔧 fixed bug when set state was called after widget was unmounted
Browse files Browse the repository at this point in the history
  • Loading branch information
sirkuryaki committed Oct 18, 2018
1 parent 50225e4 commit 8a94d88
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions lib/src/widgets/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ class QueryState extends State<Query> {
variables: widget.variables,
);

setState(() {
data = result;
error = null;
loading = false;
});
if (this.mounted) {
setState(() {
data = result;
error = null;
loading = false;
});
}
} catch (e) {
// Ignore, right?
}
Expand All @@ -95,18 +97,22 @@ class QueryState extends State<Query> {
variables: widget.variables,
);

setState(() {
data = result;
error = null;
loading = false;
});
} catch (e) {
if (data == {}) {
if (this.mounted) {
setState(() {
error = e;
data = result;
error = null;
loading = false;
});
}
} catch (e) {
if (data == {}) {
if (this.mounted) {
setState(() {
error = e;
loading = false;
});
}
}
}

if (pollInterval is Duration && !(pollTimer is Timer)) {
Expand Down

0 comments on commit 8a94d88

Please sign in to comment.