Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 80f508e

Browse files
committed
fix: if-block await invalidates mounted check
1 parent da41d1a commit 80f508e

File tree

1 file changed

+4
-5
lines changed
  • lib/src/analyzers/lint_analyzer/rules/rules_list/use_setstate_synchronously

1 file changed

+4
-5
lines changed

lib/src/analyzers/lint_analyzer/rules/rules_list/use_setstate_synchronously/visitor.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ class _AsyncSetStateVisitor extends RecursiveAstVisitor<void> {
6464
}
6565

6666
node.condition.visitChildren(this);
67-
final oldMounted = mounted;
6867
final newMounted = _extractMountedCheck(node.condition);
69-
7068
mounted = newMounted.or(mounted);
69+
7170
final beforeThen = mounted;
7271
node.thenStatement.visitChildren(this);
7372
final afterThen = mounted;
@@ -86,8 +85,6 @@ class _AsyncSetStateVisitor extends RecursiveAstVisitor<void> {
8685
mounted = beforeThen != afterThen
8786
? afterThen
8887
: _extractMountedCheck(node.condition, permitAnd: false);
89-
} else {
90-
mounted = oldMounted;
9188
}
9289
}
9390

@@ -103,7 +100,9 @@ class _AsyncSetStateVisitor extends RecursiveAstVisitor<void> {
103100
mounted = newMounted.or(mounted);
104101
node.body.visitChildren(this);
105102

106-
mounted = _blockDiverges(node.body) ? _tryInvert(newMounted) : oldMounted;
103+
if (_blockDiverges(node.body)) {
104+
mounted = _tryInvert(newMounted).or(oldMounted);
105+
}
107106
}
108107

109108
@override

0 commit comments

Comments
 (0)