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

BuildContext across async gaps with mounted check false positive with condition OR #5074

Closed
vendelin8 opened this issue Aug 22, 2024 · 1 comment
Assignees
Labels
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

@vendelin8
Copy link

Describe the issue
Lint error use_build_context_synchronously when it was already checked. It's similar to #5069 but slightly different. I cannot solve by the same way.

To Reproduce
Inside class _MyHomePageState extends State<MyHomePage>:

  Future<void> newPhoto() async {
    await showDialog(
      context: context,
      builder: (BuildContext context) => AlertDialog(
        actions: [
          TextButton(
            child: const Text('Choose a file'),
            onPressed: () async {
              if (await test() || !context.mounted) return;

              Navigator.of(context).pop();
            },
          ),
        ],
      ),
    );
  }

Expected behavior
No lint infos, because context.mounted was already checked previously.

Additional context
Upgraded repo to try: https://github.com/vendelin8/dart-lintbug

dart --version
Dart SDK version: 3.5.0 (stable) (Tue Jul 30 02:17:59 2024 -0700) on "linux_x64"
@github-actions github-actions bot added the set-flutter Affects a rule in the recommended Flutter rule set label Aug 22, 2024
@srawlins srawlins self-assigned this Aug 22, 2024
@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 labels Aug 22, 2024
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Aug 23, 2024
Fixes dart-lang/linter#5074

Change-Id: Ic4a012cbb753f1995e8e0b4fe8e444af996f46aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381901
Commit-Queue: Phil Quitslund <[email protected]>
Reviewed-by: Phil Quitslund <[email protected]>
Auto-Submit: Samuel Rawlins <[email protected]>
@srawlins
Copy link
Member

Thanks for the report! Fixed with dart-lang/sdk@14cbdb3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants