short array work and doc

This commit is contained in:
Christien Rioux 2024-03-07 08:28:05 -05:00
parent d3cdca17c5
commit 64d4d0cefb
6 changed files with 178 additions and 94 deletions

View file

@ -20,9 +20,11 @@ class PreferencesRepository {
Future<void> init() async {
final sharedPreferences = await SharedPreferences.getInstance();
// ignore: do_not_use_environment
const namespace = String.fromEnvironment('NAMESPACE');
_data = SharedPreferencesValue<Preferences>(
sharedPreferences: sharedPreferences,
keyName: 'preferences',
keyName: namespace.isEmpty ? 'preferences' : 'preferences_$namespace',
valueFromJson: (obj) =>
obj != null ? Preferences.fromJson(obj) : Preferences.defaults,
valueToJson: (val) => val.toJson());