I am getting a lot of widgets groups in the tree and wanted to start extracting them to their own widget.
I tried with Ctrl-Alt-W, this command does nothing and shows no error when there is a problem.
If you go to the top menu and click on refactor, extract, extract to widget the following error occurs:
Can only extract a widget expression or a method returning widget.
This is an example of the code I am trying to extract:
                     Expanded(
                          child: Container(
                            child: Padding(
                              padding: const EdgeInsets.only(
                                  left: 8.0,
                                  right: 8.0,
                                  top: 8.0,
                                  bottom: 4.0),
                              child: new TextField(
                                decoration: new InputDecoration(
                                    border: new OutlineInputBorder(
                                      borderRadius: const BorderRadius.all(
                                        const Radius.circular(10.0),
                                      ),
                                    ),
                                    filled: true,
                                    hintStyle: new TextStyle(
                                        color: Colors.grey[800]),
                                    hintText: "Supervisor",
                                    fillColor: Colors.white70),
                              ),
                            ),
                          ),
                        ),
How would I modify this code in the widget tree to have a return so that it can be easily extracted.
Thanks
I don't think this is a bug. Everyone says that you have to highlight all of the code to extract it, and it worked with them, but for me, I've made it like this.
First I put the cursor at the specific widget.




Ensure Two Steps:
Dont select the block, only ensure that cursor is at the first letter of the block. Then -> right click -> refactor -> extract widget and voila! It will work. Thanks. Happy Coding!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With