Open HansMuller opened 7 years ago
Adding support for this request. It would be good to add all the different variations of what could go there, I.E. Widgets where the selected widget is a Child or one of the children like we already have, and widgets where the selected widget is returned from a method, as in above. I can't think of any more currently, 😄
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) flutter_wrap_stream_builder_test
. That's the place to start!
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: https://github.com/flutter/flutter/issues/4581.