PreferencesSnapshot.fromValues constructor
Infers types on platforms that preserve them in their runtime values.
Implementation
factory PreferencesSnapshot.fromValues(Map<String, Object?> source) {
final values = copyPreferences(source);
return PreferencesSnapshot(
values,
values.map(
(key, value) => MapEntry(key, switch (value) {
String() => 'string',
bool() => 'bool',
int() => 'int',
double() => 'double',
List<String>() => 'list',
_ => throw const FormatException('Unsupported preference type.'),
}),
),
);
}