Skip to content

Remove a widget from hierarchy #1283

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

Closed
goderbauer opened this issue Aug 11, 2017 · 5 comments
Closed

Remove a widget from hierarchy #1283

goderbauer opened this issue Aug 11, 2017 · 5 comments

Comments

@goderbauer
Copy link
Member

I absolutely love the "wrap with new widget" feature. It's great!

I wish there'd also be the opposite of that, i.e. removing a widget from the hierarchy.

@stevemessick
Copy link
Member

When you are removing a widget are you also removing its children? Or are you asking for a feature that will promote some child to be the replacement for its parent?

The first case can easily be done using Edit>Extend Selection, but I can see that the second case involves more tricky editing.

@pq pq added this to the Backlog milestone Aug 30, 2017
@brianegan
Copy link
Contributor

brianegan commented Oct 1, 2017

Thanks for all the hard work and listening to this request!

I find myself wishing for this feature more and more... In my case, I'd love Option #2: to be able to "Unwrap" the child Widget / promote it to replace the parent. As you mention, Option #1 seems to be covered by core editor functionality.

Example

Start with something like this:

return new Card(
  child: new Container(
    color: Colors.red,
    padding: new EdgeInsets.only(
      top: 12.0, 
      bottom: 12.0,
    ),
    child: new Image.network(
      thumbnailUrl,
      scale: 1.0,
      fit: BoxFit.cover,
    ),
  ),
);

In my case, I want to remove the Container, but keep the child Image.network. The resulting code should look like this:

return new Card(
  child: new Image.network(
    thumbnailUrl,
    scale: 1.0,
    fit: BoxFit.cover,
  ),
);

And if we want to get crazy, remove the Card as well:

return new Image.network(
    thumbnailUrl,
    scale: 1.0,
    fit: BoxFit.cover,
);

I could see this working a couple of ways:

  1. Place the cursor over the Image.network constructor. Hit Option-Return. See two options: Wrap with new Widget & Unwrap Widget.
  2. Place the cursor over the Container widget. Hit Option-Return. See a new option: Replace with Child (or better language :)

@devoncarew
Copy link
Member

/cc @stevemessick - some feedback about a potential 'Move up' Flutter refactoring.

@scheglov
Copy link
Contributor

scheglov commented Feb 9, 2018

@scheglov scheglov closed this as completed Feb 9, 2018
dart-bot pushed a commit to dart-lang/sdk that referenced this issue Feb 9, 2018
@goderbauer
Copy link
Member Author

Cool! Can't wait to give this a try! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants