linter: Mark use_build_context_synchronously stable

Fixes https://github.com/dart-lang/linter/issues/3915



Change-Id: I4909b6440859174852f85084fef4c847f0f46a94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325365
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Sam Rawlins 2023-09-12 19:50:09 +00:00 committed by Commit Queue
parent cdf016c6ab
commit 45930e3d62
2 changed files with 3 additions and 8 deletions

View file

@ -8,6 +8,7 @@ import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:collection/collection.dart';
import 'package:pub_semver/pub_semver.dart';
import '../analyzer.dart';
import '../util/flutter_utils.dart';
@ -278,12 +279,6 @@ class AsyncStateVisitor extends SimpleAstVisitor<AsyncState> {
// After one loop, an `await` in the condition can affect the body.
return node.condition.accept(this)?.asynchronousOrNull;
} else if (node.condition == reference) {
// TODO(srawlins): The repetition gets tricky. In this code:
// `do print('hi') while (await f(context));`, the `await` is not unsafe
// for `f(context)` when just looking at the condition without looking at
// the context of the do-statement. However, as the code can loop, the
// `await` _is_ unsafe. It can unwrap to
// `print('hi'); await f(context); print('hi'); await f(context);`.
return node.body.accept(this)?.asynchronousOrNull;
} else {
return node.condition.accept(this)?.asynchronousOrNull ??
@ -793,7 +788,7 @@ class UseBuildContextSynchronously extends LintRule {
description: _desc,
details: _details,
group: Group.errors,
state: State.experimental(),
state: State.stable(since: Version(3, 2, 0)),
);
@override

View file

@ -468,7 +468,7 @@
"name": "use_build_context_synchronously",
"description": "Do not use BuildContexts across async gaps.",
"group": "errors",
"state": "experimental",
"state": "stable",
"incompatible": [],
"sets": [
"flutter"