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

Unable to obtain and re-apply defaults used during initialisation #43

Open
dylanhillier opened this issue Jul 7, 2024 · 0 comments
Open

Comments

@dylanhillier
Copy link

I'd love to be able to conveniently retrieve the defaults provided during initialization so i can "reset to defaults" in my app.
However, it would appear these defaults aren't saved anywhere within the PrefServiceShared. At first glance i thought no problem, i can just extend PrefServiceShared, cache my defaults add a getter then i realized PrefServiceShared is closed for extension. :(

for context:

  final service = await PrefServiceShared.init(
    defaults: {
      'pref_a': 0,
      'pref_b': 0,
      'pref_c': 5000,
      'pref_d': 500,
      'pref_e': 4500,
    },
  );

...
// meanwhile.. in some code far far away..
...
PrefService.of(context).resetToDefaults();  // <<--- new function

// AND/OR

PrefService.of(context).resetToDefault('pref_d');  // <<---- another new function.
...
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

No branches or pull requests

1 participant