-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Documentation error: dependOnInheritedWidgetOfExactType #47067
Comments
It appears the "should not" wording was introduced by @Hixie on Aug 29, 2016 ea6bf47#diff-16a8dc6e114c65d7a516fc759bac2316 It looks like that documentation was based on the work of @HansMuller on Aug 26, 2016 in the following commit. d0e72d6#diff-16a8dc6e114c65d7a516fc759bac2316 Is it only an assert that stops the getting of inherited widgets during |
@petermichaux Two things:
|
In the documentation, we don't really distinguish between "should not" and "cannot" because nobody stops you from forking the framework, removing whatever asserts make it "impossible", and violating the "cannot" anyway. I'll change these to "should not" for consistency, and will make sure the right behaviour is mentioned. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
From https://api.flutter.dev/flutter/widgets/BuildContext/dependOnInheritedWidgetOfExactType.html
From https://api.flutter.dev/flutter/widgets/State/initState.html
Which one is it? Is it "should not" which is a best practices recommendation or is it "cannot" which is a technical impossibility?
A common case where using the build context inside
initState
is convenient is to get some unchanging inherited widget like a services object. (A sort of dependency injection without having to pass/inject the dependency manually all the way down the widget tree.)Also there is a formatting error in the initState documentation when rendered as HTML: The last bullet point about dispose runs into the next paragraph.
The text was updated successfully, but these errors were encountered: