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

[Feature request] BaseBoxyDelegate.getChildOrNull #33

Closed
jtarkowski27 opened this issue Dec 4, 2023 · 1 comment · Fixed by #34
Closed

[Feature request] BaseBoxyDelegate.getChildOrNull #33

jtarkowski27 opened this issue Dec 4, 2023 · 1 comment · Fixed by #34

Comments

@jtarkowski27
Copy link
Contributor

For convenience sake, I'd like to suggest adding a simple non-throwable method getChildOrNull to BaseBoxyDelegate. With that it wouldn't be necessary to always write code like this:

BoxyChild? child = null;
if (hasChild(#child)) {
  child = getChild(#child);
}

Implementation is simple and would go as follows:

/// Gets the child handle with the specified [id] or returns null if there
/// is no child with given [id].
T? getChildOrNull<T extends ChildHandleType>(Object id) {
  if (hasChild(id)) {
    return getChild(id);
  }
  return null;
}
@pingbird
Copy link
Owner

pingbird commented Dec 4, 2023

This is reasonable, feel free to submit a PR!

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

Successfully merging a pull request may close this issue.

2 participants