Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/shared_preferences/shared_preferences/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.3.1

* Fixes `getStringList` bug with `List<Object?>` cast exception.

## 2.3.0

* Adds `SharedPreferencesAsync` and `SharedPreferencesWithCache` APIs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,17 @@ void main() {
expect(preferences.getStringList(listKey), testList);
});

testWidgets('get StringList handles List<Object?>',
(WidgetTester _) async {
final (
SharedPreferencesWithCache preferences,
Map<String, Object?> cache
) = await getPreferences();
final List<Object?> listObject = <Object?>['one', 'two'];
cache[listKey] = listObject;
expect(preferences.getStringList(listKey), listObject);
});

testWidgets('reloading', (WidgetTester _) async {
final (
SharedPreferencesWithCache preferences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,8 @@ class SharedPreferencesWithCache {
throw ArgumentError(
'$key is not included in the PreferencesFilter allowlist');
}
final List<String>? list = _cache[key] as List<String>?;
// Make a copy of the list so that later mutations won't propagate
return list?.toList();
return (_cache[key] as List<Object?>?)?.cast<String>().toList();
}

/// Saves a boolean [value] to the cache and platform.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for reading and writing simple key-value pairs.
Wraps NSUserDefaults on iOS and SharedPreferences on Android.
repository: https://github.com/flutter/packages/tree/main/packages/shared_preferences/shared_preferences
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22
version: 2.3.0
version: 2.3.1

environment:
sdk: ^3.3.0
Expand Down