File tree Expand file tree Collapse file tree 4 files changed +17
-1
lines changed
packages/shared_preferences Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.5.2
2
+
3
+ * Add containsKey method.
4
+
1
5
## 0.5.1+2
2
6
3
7
* Add a driver test
Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ class SharedPreferences {
70
70
/// String.
71
71
String getString (String key) => _preferenceCache[key];
72
72
73
+ /// Returns true if persistent storage the contains the given [key] .
74
+ bool containsKey (String key) => _preferenceCache.containsKey (key);
75
+
73
76
/// Reads a set of string values from persistent storage, throwing an
74
77
/// exception if it's not a string set.
75
78
List <String > getStringList (String key) {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ description: Flutter plugin for reading and writing simple key-value pairs.
3
3
Wraps NSUserDefaults on iOS and SharedPreferences on Android.
4
4
author : Flutter Team <flutter-dev@googlegroups.com>
5
5
homepage : https://github.com/flutter/plugins/tree/master/packages/shared_preferences
6
- version : 0.5.1+ 2
6
+ version : 0.5.2
7
7
8
8
flutter :
9
9
plugin :
Original file line number Diff line number Diff line change @@ -125,6 +125,15 @@ void main() {
125
125
));
126
126
});
127
127
128
+ test ('containsKey' , () async {
129
+ const String key = 'testKey' ;
130
+
131
+ expect (false , preferences.containsKey (key));
132
+
133
+ preferences.setString (key, 'test' );
134
+ expect (true , preferences.containsKey (key));
135
+ });
136
+
128
137
test ('clearing' , () async {
129
138
await preferences.clear ();
130
139
expect (preferences.getString ('String' ), null );
You can’t perform that action at this time.
0 commit comments