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

assess flutter_gallery use_build_context_synchronously breakages #3680

Closed
pq opened this issue Sep 12, 2022 · 8 comments · Fixed by flutter/flutter#111539 or flutter/gallery#782
Closed
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures set-flutter Affects a rule in the recommended Flutter rule set type-question A question about expected behavior or functionality

Comments

@pq
Copy link
Member

pq commented Sep 12, 2022

A recent fix to use_build_context_synchronously (#3679) is flagging a few places in flutter_gallery that need addressing before we can publish a new linter.

https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8803460924190469121/+/u/analyze_flutter_flutter/stdout

Naively I added some mounted checks but these won't work since the widgets are stateless and don't have a mounted property accessor (flutter/flutter#111321). We could make these diagnostics go away by limiting the lint to only check accesses from StatefulWidgets (indeed the lint docs suggest this) but there's also something fishy going on in the newly flagged calls... I'd love another set of eyes and 2 cents.

Thanks in advance!

/cc @a14n @goderbauer @jacob314

/fyi @raapperez

@pq pq added the type-question A question about expected behavior or functionality label Sep 12, 2022
@github-actions github-actions bot added the set-flutter Affects a rule in the recommended Flutter rule set label Sep 12, 2022
@pq pq added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Sep 12, 2022
@pq
Copy link
Member Author

pq commented Sep 12, 2022

(Marking P1 as this is currently roll-blocking.)

@goderbauer
Copy link
Contributor

The problem also exists for contexts of StatelessWidgets, though. One workaround is to turn the StatelessWidget into a StatefulWidget so you get access to the mounted property. I've also been thinking about adding a property to BuildContext itself so you can check right on it whether it is still valid; discussion for that is at flutter/flutter#111488.

@a14n
Copy link
Contributor

a14n commented Sep 14, 2022

flutter/flutter#111539 fixes the issue.

@pq
Copy link
Member Author

pq commented Sep 14, 2022

Thanks @a14n!

@pq pq closed this as completed Sep 14, 2022
@pq pq reopened this Sep 14, 2022
@pq
Copy link
Member Author

pq commented Sep 14, 2022

Looks like we've still got a failure:

https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8803023674715529281/+/u/analyze_flutter_gallery/stdout

Analyzing gallery...

   info - lib/pages/demo.dart:198:13 - Do not use BuildContexts across async gaps. - use_build_context_synchronously

@a14n
Copy link
Contributor

a14n commented Sep 15, 2022

flutter/gallery#782 fixes this new issue.

@pq
Copy link
Member Author

pq commented Sep 15, 2022

Thanks for the quick fix!

@pq
Copy link
Member Author

pq commented Sep 16, 2022

image

Thanks!

@pq pq closed this as completed Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures set-flutter Affects a rule in the recommended Flutter rule set type-question A question about expected behavior or functionality
Projects
None yet
3 participants