Skip to content
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

How to remove a rendered widget? #16

Closed
rupinderjeet opened this issue Apr 28, 2022 · 4 comments
Closed

How to remove a rendered widget? #16

rupinderjeet opened this issue Apr 28, 2022 · 4 comments
Labels
question A question and not an issue

Comments

@rupinderjeet
Copy link

In onLayout(), I have some code like this:

final source = getChild(#source);
final sourceSize = source.layout(constraints);
source.position(const Offset(-10000, 0));

I am using sourceSize to determine source's size and apply this size to another widget. This is working for me. But, I want to remove source completely instead of hiding it at (-10000, 0). How can I do this?

@pingbird
Copy link
Owner

Call source.ignore(): https://pub.dev/documentation/boxy/latest/boxy/BaseBoxyChild/ignore.html

@pingbird pingbird added the question A question and not an issue label Apr 29, 2022
@rupinderjeet
Copy link
Author

Thank you. This has helped me remove weird offset I was using. However, I have two more related questions.

  1. Is the order of using ignore correct in below code?
final source = getChild(#source);
final sourceSize = source.layout(constraints);
source.position(Offset.zero);
source.ignore();
  1. On a page, If a Hero widget, with tag photo_hero, is nested as a child of this dummy source widget, Boxy will layout it to get the size. But, this also means that I can no longer use the same Hero tag on that page again. Is this right? Hero widget tagged with photo_hero will be used with source widget and I will somehow need to tell actual widget and its Hero widget to use a different tag. Is this right?

@pingbird
Copy link
Owner

pingbird commented May 2, 2022

Yes, that is correct, the child still exists in the Element tree preventing you from having an identical Hero. I'm not sure if the framework allows you to create and destroy a child in the same layout pass, that requires some more testing.

@rupinderjeet
Copy link
Author

Thank you for your help and this project. There is a lot to learn for me in this codebase. You can close this issue, my query is answered.

@pingbird pingbird closed this as completed May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question and not an issue
Projects
None yet
Development

No branches or pull requests

2 participants