-
Notifications
You must be signed in to change notification settings - Fork 324
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
Flutter IDE Wish: wrap with a builder, a stateful builder, or a layout builder #814
Comments
Adding support for this request. It would be good to add all the different variations of what could go there, I.E. |
This is a feature I've need consistently for the past 2 years. I am happy to implement it. I have found the locations of where the current StreamBuilder wrapper is.
@pq Would you be able to assist me with the approach to running and testing my edits locally? |
Cool! @slightfoot: in IDEA, you should be able to simply run (and debug) |
Fixes issues such as * flutter/flutter-intellij#814 * #33957 . Essentially, in Flutter, it's often useful to create a new context in the UI/widget tree as a place to begin a search towards the trunk of the tree for various state structures attached to lower levels of the tree. The basic `Builder` widget is the official means for creating such a context/entry-point. The patches in this PR are essentially a copy-paste-tweak from two types of existing, similar assists. The main origin was taken from `FlutterWrapStreamBuilder` which wraps client code with a constructor for the StreamBuilder sub-class. The new assist, provided here, is a little more basic/general than the StreamBuilder so it was able to also adopt assertion and test code from some of the other assists for basic widgets. Closes #45656 #45656 GitOrigin-RevId: 00a5043 Change-Id: I5f93837af571b4974e35da131112f82cd9359697 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194941 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
Looks like #45656 added the Builder widget. |
Another useful variation on the
wrap this new widget expression
with another new widget idiom: inserting a new expression for one of the common widget builder classes, Builder, StatefulBuilder, LayoutBuilder.There are some idomatic scenarios where a Builder widget is needed. For example.
If you write something like the following and then try pressing the button, the
Scaffold.of(context)
expression will fail because the context doesn't actually include the Scaffold.Wrapping the button in a builder corrects the problem because the Scaffold is within the parent of the Builder's BuildContext.
I've called the Builder function's BuildContext parameter
scaffoldContext
for clarity. I don't think that sort of rename would be possible for the IDE to generate.It would be really impressive if the analyzer could detect the origin
Scaffold.of(context)
and the IDE could suggest this remedy.Just FTR, the potential difficulty of referring to inherited widgets defined in the same build function is also noted here: flutter/flutter#4581.
The text was updated successfully, but these errors were encountered: