Skip to content

Remove deprecated methods from BuildContext #69620

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

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

goderbauer
Copy link
Member

@goderbauer goderbauer commented Nov 2, 2020

Description

This removes the deprecated BuildContext methods that has reached the EOL . See table below:

Before After
inheritFromElement dependOnInheritedElement
inheritFromWidgetOfExactType dependOnInheritedWidgetOfExactType
ancestorInheritedElementForWidgetOfExactType getElementForInheritedWidgetOfExactType
ancestorWidgetOfExactType findAncestorWidgetOfExactType
ancestorStateOfType findAncestorStateOfType
rootAncestorStateOfType findRootAncestorStateOfType
ancestorRenderObjectOfType findAncestorRenderObjectOfType

Similar methods exist on the Element class and will be removed from there in #72903.

Part of deprecations that are slated for removal for next release in https://flutter.dev/go/deprecation-lifetime

More context: https://medium.com/flutter/deprecation-lifetime-in-flutter-e4d76ee738ad

Related Issues

Deprecated in #44189

Tests

Tests for quick fix tool.

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

Sorry, something went wrong.

@flutter-dashboard flutter-dashboard bot added framework flutter/packages/flutter repository. See also f: labels. work in progress; do not review labels Nov 2, 2020
@google-cla google-cla bot added the cla: yes label Nov 2, 2020
@@ -0,0 +1,134 @@
# Spec file for "dart fix", see <insert URL>.
Copy link
Member Author

Choose a reason for hiding this comment

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

@bwilkerson Where can we link to here?

Copy link
Contributor

@bwilkerson bwilkerson Nov 3, 2020

Choose a reason for hiding this comment

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

We don't currently have a published version of the docs. They'll be the contents of the "User documentation" doc you've seen. I'd like to flesh them out a bit more before publishing them, but if we need them to be published sooner than that let me know.

Any additional feedback you have on the doc as a result of using it while writing this file would be much appreciated. (With thanks for your previous comment about adding some complete examples.)

- title: 'Rename to dependOnInheritedElement'
date: 2019-11-22
element:
uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
Copy link
Member Author

@goderbauer goderbauer Nov 2, 2020

Choose a reason for hiding this comment

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

I can see that coming up with the correct list here will be difficult. It will be easy to miss a lib that exports the symbol...

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a valid concern.

The design tradeoff is that we have less information that we can use to ensure that we're selecting the correct change in the case where a declaration has been removed. Having the URIs doesn't absolutely guarantee that we won't do the wrong thing, but it does make it significantly less likely. Unfortunately, I don't have concrete numbers for how often we'd do the wrong thing (either with or without them), but I am concerned about the effect on user trust if the tool makes incorrect changes.

@goderbauer
Copy link
Member Author

/cc @Piinks

@goderbauer
Copy link
Member Author

We have to come up with a way to test these fixes. @bwilkerson Have you already given testing these definitions some thoughts?

changes:
- kind: 'rename'
newName: 'dependOnInheritedElement'
- title: 'Migrate to dependOnInheritedWidgetOfExactType'
Copy link
Member

Choose a reason for hiding this comment

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

As a drive by comment, you may want liberal use of whitespace and # comments to help separate the individual refactors. This file will likely get pretty large and will be tough to navigate w/o some visual separation between fixes.

Copy link
Member Author

@goderbauer goderbauer Nov 3, 2020

Choose a reason for hiding this comment

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

Agreed and done.

version: 1
transforms:
# Change made in https://github.com/flutter/flutter/pull/44189.
- title: 'Rename to dependOnInheritedElement'
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless the distinction is important to users we ought to be consistent in the naming of these actions. Consider changing "Rename" to "Migrate".

@Piinks
Copy link
Contributor

Piinks commented Dec 23, 2020

@goderbauer do you want to move forward with this change?

@Piinks
Copy link
Contributor

Piinks commented Dec 23, 2020

The tests that need to be added here are almost the same as #72903
This change will need to land before that one.

@Piinks Piinks mentioned this pull request Dec 23, 2020
9 tasks
@goderbauer
Copy link
Member Author

@goderbauer do you want to move forward with this change?

Yes, I'll update this PR.

@goderbauer goderbauer changed the title Add fix_data.yaml with first 7 fixes Remove deprecated methods from BuildContext Jan 7, 2021
@flutter-dashboard flutter-dashboard bot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. labels Jan 7, 2021
@goderbauer goderbauer marked this pull request as ready for review January 7, 2021 22:22
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@goderbauer goderbauer requested a review from Piinks January 7, 2021 22:22

# Change made in https://github.com/flutter/flutter/pull/44189.
- title: 'Migrate to ancestorRenderObjectOfType'
date: 2019-11-22
Copy link
Contributor

Choose a reason for hiding this comment

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

Oooh I see, this is the date of the deprecation? (#44189 here?)

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Flutter_LGTM
Thank you!

@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@Piinks Piinks added the c: API break Backwards-incompatible API changes label Jan 8, 2021
@Piinks
Copy link
Contributor

Piinks commented Jan 8, 2021

Google tests have been fixed, this has a merge conflict now though. Strange Resolve conflicts is disabled here.

Unverified

This user has not yet uploaded their public signing key.
@goderbauer
Copy link
Member Author

Merge conflict is resolved.

@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: API break Backwards-incompatible API changes f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants