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 - add convenience methods scope.getStates{orNull} #182

Merged
merged 1 commit into from Mar 9, 2023

Conversation

beeth0ven
Copy link
Contributor

@beeth0ven beeth0ven commented Mar 8, 2023

Why

Since scope.get<States<T>>() is a high-frequency called api with flutter context. But the keystroke is not very smooth.

What

ScopeGetStatesX is an extension to ScopeGet that adds convenience methods like scope.getStates, scope.getStatesOrNull and scope.hasStates.

extension ScopeGetStatesX on ScopeGet {

  States<T>? getStatesOrNull<T>({
    Object? name,
  }) => getOrNull<States<T>>(name: name);

  States<T> getStates<T>({
    Object? name,
  }) => get<States<T>>(name: name);

  bool hasStates<T>({
    Object? name,
  }) => has<States<T>>(name: name);
}

How

Changes:

- scope.get<States<String>>();
+ scope.getStates<String>();
- scope.has<States<String>>();
+ scope.hasStates<String>();

With ScopeGetStatesX extension methods, the keystroke is much more smooth, which will bring better development experience.

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change

Comparison is base (79f9004) 100.00% compared to head (56e5c78) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #182   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           38        39    +1     
  Lines          473       479    +6     
=========================================
+ Hits           473       479    +6     
Impacted Files Coverage Δ
...c/dart_scope/scope_methods/scope_get_states_x.dart 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@beeth0ven beeth0ven merged commit 9e36182 into main Mar 9, 2023
@beeth0ven beeth0ven deleted the feature/scope-get-states branch March 9, 2023 00:41
@beeth0ven beeth0ven mentioned this pull request Mar 9, 2023
9 tasks
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.

None yet

1 participant