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

Added New method Get.findOrNull () #2837

Merged
merged 2 commits into from
Jul 17, 2023
Merged

Added New method Get.findOrNull () #2837

merged 2 commits into from
Jul 17, 2023

Conversation

aryan-more
Copy link
Contributor

@aryan-more aryan-more commented Jul 3, 2023

Implemented findOrNull method

This pull request adds a new method called findOrNull to GetX. The method is similar to the existing find method but instead of throwing an error when the specified dependency is not found, it returns null.

This methods aims to avoid writing more boilerplate code like this

if (Get.isRegistered<ControllerX>()){
  Get.find<ControllerX>().refresh();
}

To this

Get.findOrNull<ControllerX>()?.refresh();

Pre-launch Checklist

  • [ Done] I updated/added relevant documentation (doc comments with ///).
  • [ Done] I added new tests to check the change I am making or feature I am adding, or @jonataslaw said the PR is test-exempt.
  • [Partial] All existing and new tests are passing. There is one test in example failing but it was also failing before making changes

Implemented findOrNull method
@aryan-more aryan-more changed the title Update extension_instance.dart Added New method Get.findOrNull () Jul 3, 2023
@aryan-more
Copy link
Contributor Author

@jonataslaw

@jonataslaw
Copy link
Owner

Thank you for your contribution!
LGTM

@jonataslaw jonataslaw merged commit 6c2ff16 into jonataslaw:master Jul 17, 2023
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 this pull request may close these issues.

2 participants