Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_build_context_synchronously false positive when using if case #4795

Closed
quoc-huynh-cosee opened this issue Oct 25, 2023 · 1 comment
Closed
Assignees
Labels
false-negative false-positive P3 A lower priority bug or feature request set-flutter Affects a rule in the recommended Flutter rule set type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@quoc-huynh-cosee
Copy link

quoc-huynh-cosee commented Oct 25, 2023

Describe the issue
I'm receiving a use_build_context_synchronously lint warning using if case with the given example, although there is a context.mounted check.

To Reproduce

Future<void> doSomething() async {}

Future<void> myMethod(BuildContext context, dynamic value) async {
  await doSomething();

  if (value case final int value when context.mounted) {
    final size = MediaQuery.of(context);
  }
}

Expected behavior
No lint warning.

Versions

  • Dart 3.1.4
  • Flutter 3.13.8
@github-actions github-actions bot added the set-flutter Affects a rule in the recommended Flutter rule set label Oct 25, 2023
@pq
Copy link
Member

pq commented Oct 25, 2023

/fyi @stereotype441

@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request false-positive false-negative labels Oct 26, 2023
@srawlins srawlins self-assigned this Oct 26, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Oct 26, 2023
Fixes dart-lang/linter#4795

Change-Id: I4cce15ddaf8a669921646fa81dd0e455859e46e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332361
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-negative false-positive P3 A lower priority bug or feature request set-flutter Affects a rule in the recommended Flutter rule set type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants