Unable to obtain and re-apply defaults used during initialisation
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 17
- Forks
- 10
- Avg merge
- 28m
- Merged PRs (30d)
- 1
Description
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.
...
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading PrefServiceShared.init and the PrefService.of(context) entry point to understand how initialization defaults are handled. Define how defaults are retained and exposed for both resetting all preferences and resetting one key, then verify that both requested reset calls restore the values shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100