Fix per-app proxy selection

This commit is contained in:
problematicconsumer
2023-09-14 12:56:22 +03:30
parent ea6f8b5fad
commit 90fa8455ac
2 changed files with 17 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ class Pref<T> with InfraLogger {
/// Updates the value asynchronously.
Future<void> update(T value) async {
loggy.debug("updating preference [$key] to [$value]");
loggy.debug("updating preference [$key]($T) to [$value]");
try {
if (mapTo != null && mapFrom != null) {
await prefs.setString(key, mapTo!(value));
@@ -45,10 +45,12 @@ class Pref<T> with InfraLogger {
T getValue() {
try {
loggy.debug("getting persisted preference [$key]");
loggy.debug("getting persisted preference [$key]($T)");
if (mapTo != null && mapFrom != null) {
final persisted = prefs.getString(key);
return persisted != null ? mapFrom!(persisted) : defaultValue;
} else if (T == List<String>) {
return prefs.getStringList(key) as T ?? defaultValue;
}
return prefs.get(key) as T? ?? defaultValue;
} catch (e) {