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 negative when checking mounted for different BuildContext #5123

Open
AhmedLSayed9 opened this issue Nov 6, 2024 · 1 comment
Labels
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

@AhmedLSayed9
Copy link

AhmedLSayed9 commented Nov 6, 2024

Describe the issue
When using multiple BuildContext, use_build_context_synchronously is not triggered if I checked .mounted for a different BuildContext.

To Reproduce

Future<void> f1(BuildContext context, BuildContext anotherContext) async {
  await Future<void>.delayed(Duration.zero);
  // print(context.size);  //this triggers fine
  if (anotherContext.mounted) print(context.size);
}

Expected behavior
The linter should trigger as I've not checked for context.mounted.

@github-actions github-actions bot added the set-flutter Affects a rule in the recommended Flutter rule set label Nov 6, 2024
@srawlins
Copy link
Member

srawlins commented Nov 6, 2024

Good catch 😁 Don't expect this to be fixed any time soon. I think I'm just going to document this as a limitation of the rule.

@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants