[go: nahoru, domu]

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

Add maybeOf for all the cases where of returns nullable. #114120

Merged
merged 5 commits into from
Oct 31, 2022

Conversation

gspencergoog
Copy link
Contributor
@gspencergoog gspencergoog commented Oct 27, 2022

Description

This fixes all of the cases in our codebase where we have an of static method that returns a nullable value, making it return non-nullable and assert if the item is not found. It also adds an associated maybeOf that returns a nullable version.

This is likely to cause a bunch of breakage, but it will also never get easier to do, as more and more people use the "wrong" API.

cc @goderbauer

@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation f: cupertino flutter/packages/flutter/cupertino repository f: focus Focus traversal, gaining or losing focus f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels. labels Oct 27, 2022
@gspencergoog gspencergoog added c: tech-debt Technical debt, code quality, testing, etc. and removed a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. f: cupertino flutter/packages/flutter/cupertino repository d: examples Sample code and demos f: routes Navigator, Router, and related APIs. f: focus Focus traversal, gaining or losing focus labels Oct 27, 2022
@gspencergoog gspencergoog force-pushed the maybe_of_fixes branch 3 times, most recently from ca68f15 to 8f18bf2 Compare October 27, 2022 15:49
Copy link
Member
@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favor of this clean-up! Thanks for doing this.

How do we roll this into google3? Do we need to do this in multiple steps (e.g. add the maybeof methods first, migrate internally, then tighten the of methods)?

Also, we should write a quick migration guide about this for the website.

@goderbauer
Copy link
Member

Looks like it is failing a bunch of our own checks. But the customer testing check is green. Maybe this is less breaking in the wild then I would have expected?

I wonder how many instances in google3 then needs updating. If its just a handful, maybe we can do a g3fix instead...

@gspencergoog gspencergoog force-pushed the maybe_of_fixes branch 4 times, most recently from 8fe8d6e to 132f86b Compare October 27, 2022 20:03
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 1, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 1, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 1, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 1, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 1, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 1, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 2, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 2, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 2, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 2, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 3, 2022
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 3, 2022
* 4f19a9fa4 [flutter_tools] Add support for compiling shaders to JSON bundle for web (flutter/flutter#114295)

* f186e1bd3 Roll pub packages (flutter/flutter#114363)

* 0c7ee5869 Make `Linux_android  android_semantics_integration_test` flaky (flutter/flutter#114361)

* 7ab2bf8ff Delete flutter_migrate code (flutter/flutter#114253)

* 0d26c51e7 Roll Flutter Engine from e432d6fc3a9b to ef4acbfe67ac (2 revisions) (flutter/flutter#114367)

* af44c0599 Roll Flutter Engine from ef4acbfe67ac to 9ba3de8f078d (1 revision) (flutter/flutter#114368)

* 7979c8744 Roll Flutter Engine from 9ba3de8f078d to ef45b5ac5b4b (1 revision) (flutter/flutter#114370)

* c1a08463e Roll Flutter Engine from ef45b5ac5b4b to 96c0353790a2 (2 revisions) (flutter/flutter#114372)

* a75c1ff05 Roll Flutter Engine from 96c0353790a2 to 1a8ba7c5521a (1 revision) (flutter/flutter#114375)

* b20b7d995 Roll Flutter Engine from 1a8ba7c5521a to c16e2c08724c (1 revision) (flutter/flutter#114379)

* 37b72342b Add `maybeOf` for all the cases where `of` returns nullable. (flutter/flutter#114120)

* 6edbaa763 Roll Flutter Engine from c16e2c08724c to 034a2da497d9 (2 revisions) (flutter/flutter#114387)

* 4851401f0 Roll Flutter Engine from 034a2da497d9 to f721db653dd1 (1 revision) (flutter/flutter#114389)

* c2edb20f3 Added token files for badges and lists. (flutter/flutter#114382)

* 0f1d0e39e 🎨 Improve exceptions thrown by asset bundle (flutter/flutter#114313)

* 3894a069b Minor code cleanup: remove redundant return (flutter/flutter#114290)

* 0e9819468 Add Material 3 support for BottomAppBar (flutter/flutter#106525)

* 210a2aa37 Revert "Add Material 3 support for BottomAppBar" (flutter/flutter#114421)

* 2bf666c17 Roll Flutter Engine from f721db653dd1 to 78ca5609d1cb (2 revisions) (flutter/flutter#114396)

* d2ad439c0 Roll Flutter Engine from 78ca5609d1cb to 31a21c75d016 (1 revision) (flutter/flutter#114426)

* b03a7b5df Roll Plugins from 91d7fe5 to 5c11747 (7 revisions) (flutter/flutter#114427)

* 70a95d57c Mark `Linux_android new_gallery__transition_perf` flaky (flutter/flutter#114429)

* 0d65b630f Roll Flutter Engine from 31a21c75d016 to e013908440cd (1 revision) (flutter/flutter#114430)

* 8a8b36177 Use hintText's TextStyle overflow (flutter/flutter#114378)

* e6b429694 Roll Flutter Engine from e013908440cd to a98c82a5e583 (1 revision) (flutter/flutter#114438)

* d0afbd72a Revert "Overlay always applies clip (#113770)" (flutter/flutter#114442)

* 93b004255 Handle dragging improvements (flutter/flutter#114042)

* dc1cedd60 Roll Flutter Engine from a98c82a5e583 to c1e1a089fa16 (4 revisions) (flutter/flutter#114444)

* 8fe872877 Roll Flutter Engine from c1e1a089fa16 to f4da34f1f6a8 (4 revisions) (flutter/flutter#114449)

* eadda3c39 Add Material 3 Popup Menu example and update existing example (flutter/flutter#114228)

* fb9065fe0 `Layer ... was previously used as oldLayer` assertion error in debug mode, and page being blank in release mode, caused by LeaderLayer addToScene bug (flutter/flutter#113998)

* e37ab48bc Introduce debugWithActiveLayoutCleared to avoid duplicated code (flutter/flutter#114003)

* c23b5ca7d Fix `addToScene` documentation (flutter/flutter#113987)

* 61deaef5d Fix bug that`timeDilation` is not reset, causing subsequent test errors, and add verifications to ensure such problem does not exist in the future (flutter/flutter#113830)

* 17ec3b1d1 [flutter_tools] Introducing arg option for specifying the output directory for web (flutter/flutter#113076)

* 17df76ba8 Roll Flutter Engine from f4da34f1f6a8 to e95a7ae83097 (1 revision) (flutter/flutter#114453)

* f10021b37 Roll Flutter Engine from e95a7ae83097 to 81f5c30b23f3 (6 revisions) (flutter/flutter#114464)

* 97d0247d5 Add Material 3 support for `Slider` - Part 1 (flutter/flutter#114079)

* 0b0e348e0 Roll Flutter Engine from 81f5c30b23f3 to 85c23bc12c56 (3 revisions) (flutter/flutter#114471)

* 6c87d7303 Roll Flutter Engine from 85c23bc12c56 to c05c8a8834ca (1 revision) (flutter/flutter#114476)

* dbc612380 Roll Flutter Engine from c05c8a8834ca to 32faadb330fc (2 revisions) (flutter/flutter#114479)

* 4b3147386 Roll Flutter Engine from 32faadb330fc to f9abfc5964c9 (1 revision) (flutter/flutter#114480)

* b2d9f9e16 Roll Flutter Engine from f9abfc5964c9 to 9a741295e793 (2 revisions) (flutter/flutter#114487)

* 9d9b0e509 Roll Flutter Engine from 9a741295e793 to 03d5b933164c (1 revision) (flutter/flutter#114489)

* 1a150ff46 Roll Flutter Engine from 03d5b933164c to 9ef5c9b0107b (2 revisions) (flutter/flutter#114492)

* 6a66aa282 Add Material 3 support for BottomAppBar (reland #106525) (flutter/flutter#114439)

* dca6f10a6 Roll Flutter Engine from 9ef5c9b0107b to f5eb26e3f763 (1 revision) (flutter/flutter#114494)

* 45c3b028c Roll Flutter Engine from f5eb26e3f763 to fed311918037 (2 revisions) (flutter/flutter#114501)

* 9f2339173 [web] Changes to web keyboard selection shortcuts for more consistent behavior (flutter/flutter#114264)

* db381d75b Roll Flutter Engine from fed311918037 to cdfd9d0ad69b (2 revisions) (flutter/flutter#114513)

* 1cfdac4b2 Always invoke impeller ios shader target (flutter/flutter#114451)

* 0e70a97e2 Refactor Animated[List, Grid, SliverList, SliverGrid] to share common code (flutter/flutter#113793)

* 1f7bacff4 Marks Linux build_tests_2_3 to be unflaky (flutter/flutter#114527)

* 307987339 [flutter_tools/dap] Map org-dartlang-sdk URIs to the location of the source files found by the analyzer (flutter/flutter#114369)

* 78dbe6661 Roll Flutter Engine from cdfd9d0ad69b to 4d1d7a41ebd2 (1 revision) (flutter/flutter#114532)

* 3b0f8335e [flutter_tools/dap] Add a base Flutter adapter class to avoid duplication between adapters (flutter/flutter#114533)

* 0211df9cf [flutter_tools] provide --timeout option to flutter drive (flutter/flutter#114458)

* 475ccd4ed Roll Flutter Engine from 4d1d7a41ebd2 to edb049257b52 (2 revisions) (flutter/flutter#114534)

* 89418ef85 Added tokens for Snackbar widget. (flutter/flutter#114466)

* b23c7809f Roll Flutter Engine from edb049257b52 to e43555ad3b94 (1 revision) (flutter/flutter#114540)

* 15867a612 Roll gallery to b6728704a6441ac37a21e433a1e43c990780d47b (flutter/flutter#114537)

* 92a66683a Roll Flutter Engine from e43555ad3b94 to 840a7b346216 (4 revisions) (flutter/flutter#114546)

* e6300da2c [tools]validation basic Xcode settings for build ipa (flutter/flutter#113412)
percula pushed a commit to percula/packages that referenced this pull request Nov 17, 2022
…r#2776)

* 4f19a9fa4 [flutter_tools] Add support for compiling shaders to JSON bundle for web (flutter/flutter#114295)

* f186e1bd3 Roll pub packages (flutter/flutter#114363)

* 0c7ee5869 Make `Linux_android  android_semantics_integration_test` flaky (flutter/flutter#114361)

* 7ab2bf8ff Delete flutter_migrate code (flutter/flutter#114253)

* 0d26c51e7 Roll Flutter Engine from e432d6fc3a9b to ef4acbfe67ac (2 revisions) (flutter/flutter#114367)

* af44c0599 Roll Flutter Engine from ef4acbfe67ac to 9ba3de8f078d (1 revision) (flutter/flutter#114368)

* 7979c8744 Roll Flutter Engine from 9ba3de8f078d to ef45b5ac5b4b (1 revision) (flutter/flutter#114370)

* c1a08463e Roll Flutter Engine from ef45b5ac5b4b to 96c0353790a2 (2 revisions) (flutter/flutter#114372)

* a75c1ff05 Roll Flutter Engine from 96c0353790a2 to 1a8ba7c5521a (1 revision) (flutter/flutter#114375)

* b20b7d995 Roll Flutter Engine from 1a8ba7c5521a to c16e2c08724c (1 revision) (flutter/flutter#114379)

* 37b72342b Add `maybeOf` for all the cases where `of` returns nullable. (flutter/flutter#114120)

* 6edbaa763 Roll Flutter Engine from c16e2c08724c to 034a2da497d9 (2 revisions) (flutter/flutter#114387)

* 4851401f0 Roll Flutter Engine from 034a2da497d9 to f721db653dd1 (1 revision) (flutter/flutter#114389)

* c2edb20f3 Added token files for badges and lists. (flutter/flutter#114382)

* 0f1d0e39e 🎨 Improve exceptions thrown by asset bundle (flutter/flutter#114313)

* 3894a069b Minor code cleanup: remove redundant return (flutter/flutter#114290)

* 0e9819468 Add Material 3 support for BottomAppBar (flutter/flutter#106525)

* 210a2aa37 Revert "Add Material 3 support for BottomAppBar" (flutter/flutter#114421)

* 2bf666c17 Roll Flutter Engine from f721db653dd1 to 78ca5609d1cb (2 revisions) (flutter/flutter#114396)

* d2ad439c0 Roll Flutter Engine from 78ca5609d1cb to 31a21c75d016 (1 revision) (flutter/flutter#114426)

* b03a7b5df Roll Plugins from 91d7fe5 to 5c11747 (7 revisions) (flutter/flutter#114427)

* 70a95d57c Mark `Linux_android new_gallery__transition_perf` flaky (flutter/flutter#114429)

* 0d65b630f Roll Flutter Engine from 31a21c75d016 to e013908440cd (1 revision) (flutter/flutter#114430)

* 8a8b36177 Use hintText's TextStyle overflow (flutter/flutter#114378)

* e6b429694 Roll Flutter Engine from e013908440cd to a98c82a5e583 (1 revision) (flutter/flutter#114438)

* d0afbd72a Revert "Overlay always applies clip (#113770)" (flutter/flutter#114442)

* 93b004255 Handle dragging improvements (flutter/flutter#114042)

* dc1cedd60 Roll Flutter Engine from a98c82a5e583 to c1e1a089fa16 (4 revisions) (flutter/flutter#114444)

* 8fe872877 Roll Flutter Engine from c1e1a089fa16 to f4da34f1f6a8 (4 revisions) (flutter/flutter#114449)

* eadda3c39 Add Material 3 Popup Menu example and update existing example (flutter/flutter#114228)

* fb9065fe0 `Layer ... was previously used as oldLayer` assertion error in debug mode, and page being blank in release mode, caused by LeaderLayer addToScene bug (flutter/flutter#113998)

* e37ab48bc Introduce debugWithActiveLayoutCleared to avoid duplicated code (flutter/flutter#114003)

* c23b5ca7d Fix `addToScene` documentation (flutter/flutter#113987)

* 61deaef5d Fix bug that`timeDilation` is not reset, causing subsequent test errors, and add verifications to ensure such problem does not exist in the future (flutter/flutter#113830)

* 17ec3b1d1 [flutter_tools] Introducing arg option for specifying the output directory for web (flutter/flutter#113076)

* 17df76ba8 Roll Flutter Engine from f4da34f1f6a8 to e95a7ae83097 (1 revision) (flutter/flutter#114453)

* f10021b37 Roll Flutter Engine from e95a7ae83097 to 81f5c30b23f3 (6 revisions) (flutter/flutter#114464)

* 97d0247d5 Add Material 3 support for `Slider` - Part 1 (flutter/flutter#114079)

* 0b0e348e0 Roll Flutter Engine from 81f5c30b23f3 to 85c23bc12c56 (3 revisions) (flutter/flutter#114471)

* 6c87d7303 Roll Flutter Engine from 85c23bc12c56 to c05c8a8834ca (1 revision) (flutter/flutter#114476)

* dbc612380 Roll Flutter Engine from c05c8a8834ca to 32faadb330fc (2 revisions) (flutter/flutter#114479)

* 4b3147386 Roll Flutter Engine from 32faadb330fc to f9abfc5964c9 (1 revision) (flutter/flutter#114480)

* b2d9f9e16 Roll Flutter Engine from f9abfc5964c9 to 9a741295e793 (2 revisions) (flutter/flutter#114487)

* 9d9b0e509 Roll Flutter Engine from 9a741295e793 to 03d5b933164c (1 revision) (flutter/flutter#114489)

* 1a150ff46 Roll Flutter Engine from 03d5b933164c to 9ef5c9b0107b (2 revisions) (flutter/flutter#114492)

* 6a66aa282 Add Material 3 support for BottomAppBar (reland #106525) (flutter/flutter#114439)

* dca6f10a6 Roll Flutter Engine from 9ef5c9b0107b to f5eb26e3f763 (1 revision) (flutter/flutter#114494)

* 45c3b028c Roll Flutter Engine from f5eb26e3f763 to fed311918037 (2 revisions) (flutter/flutter#114501)

* 9f2339173 [web] Changes to web keyboard selection shortcuts for more consistent behavior (flutter/flutter#114264)

* db381d75b Roll Flutter Engine from fed311918037 to cdfd9d0ad69b (2 revisions) (flutter/flutter#114513)

* 1cfdac4b2 Always invoke impeller ios shader target (flutter/flutter#114451)

* 0e70a97e2 Refactor Animated[List, Grid, SliverList, SliverGrid] to share common code (flutter/flutter#113793)

* 1f7bacff4 Marks Linux build_tests_2_3 to be unflaky (flutter/flutter#114527)

* 307987339 [flutter_tools/dap] Map org-dartlang-sdk URIs to the location of the source files found by the analyzer (flutter/flutter#114369)

* 78dbe6661 Roll Flutter Engine from cdfd9d0ad69b to 4d1d7a41ebd2 (1 revision) (flutter/flutter#114532)

* 3b0f8335e [flutter_tools/dap] Add a base Flutter adapter class to avoid duplication between adapters (flutter/flutter#114533)

* 0211df9cf [flutter_tools] provide --timeout option to flutter drive (flutter/flutter#114458)

* 475ccd4ed Roll Flutter Engine from 4d1d7a41ebd2 to edb049257b52 (2 revisions) (flutter/flutter#114534)

* 89418ef85 Added tokens for Snackbar widget. (flutter/flutter#114466)

* b23c7809f Roll Flutter Engine from edb049257b52 to e43555ad3b94 (1 revision) (flutter/flutter#114540)

* 15867a612 Roll gallery to b6728704a6441ac37a21e433a1e43c990780d47b (flutter/flutter#114537)

* 92a66683a Roll Flutter Engine from e43555ad3b94 to 840a7b346216 (4 revisions) (flutter/flutter#114546)

* e6300da2c [tools]validation basic Xcode settings for build ipa (flutter/flutter#113412)
@rydmike
Copy link
Contributor
rydmike commented Jan 30, 2023

@gspencergoog and @goderbauer the staged approach mentioned here #114120 (review) would have been very nice imo too.

Now I found all these .of breaking changes in 3.7 stable compared to 3.3. Migrating an app is not so bad and the autofix is there to help, fairly small issue in app to be honest.

However, when it comes to packages, I see no other way than to release a new version that breaks backwards compatibility with Flutter 3.3, just to keep things happy, working and safe with this change. Which is a bit sad. By doing a staged add of .maybeOf in this stable, warn about the coming tightening of .of and then in next stable tighten .of to none nullable, things could have been kept a bit smoother for pub package migrations by providing this overlapping grace period.

For info, I just mentioned this breaking change in a tweet here https://twitter.com/RydMike/status/1619906370584875010

I had a bit of not again deja vu with the similar changes from Flutter 2.0.0. At least then there was a major version bump to "justify" the wide .of breaks. sure, this is not quite as wide spread and the impacted APIs are certainly a lot less common, but still... oh well, we will just have rip off that band-aid at once then and break with past packages. Sure it is quicker this way 🤷🏻‍♂️ 😄

rydmike added a commit to rydmike/website that referenced this pull request Jan 31, 2023
The `Overlay.of` breaking change is missing in 3.7 breaking changes doc page. It was done in a separate PR flutter/flutter#110811 earlier than the bulk of the other changes in flutter/flutter#114120
sfshaza2 pushed a commit to flutter/website that referenced this pull request Jan 31, 2023
The `Overlay.of` breaking change is missing in 3.7 breaking changes doc page. It was done in a separate PR flutter/flutter#110811 earlier than the bulk of the other changes in flutter/flutter#114120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App c: tech-debt Technical debt, code quality, testing, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository f: focus Focus traversal, gaining or losing focus f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants