Skip to content

Commit 7831591

Browse files
committed
Add back the removed "get" method so as not to break compatibility
1 parent b5310bb commit 7831591

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

ios/Classes/SharedPreferenceAppGroupPlugin.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ - (void)setStringArray:(FlutterMethodCall *)call result:(FlutterResult)result {
9797
result(nil);
9898
}
9999

100+
- (void)get:(FlutterMethodCall *)call result:(FlutterResult)result {
101+
[self checkAppGroup:result];
102+
103+
NSString *key = call.arguments[@"key"];
104+
id value = [self.userDefaults valueForKey:key];
105+
result(value);
106+
}
107+
100108
- (void)getBool:(FlutterMethodCall *)call result:(FlutterResult)result {
101109
[self checkAppGroup:result];
102110

lib/shared_preference_app_group.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class SharedPreferenceAppGroup {
4848
await _setValue('StringArray', key, value);
4949
}
5050

51+
/// Reads a value of any type from persistent storage under the specified app group.
52+
///
53+
/// If the persistent storage does not contains [key], then [null] will be returned
54+
static Future<dynamic> get(String key) async {
55+
return await _channel.invokeMethod('get', {'key': key});
56+
}
57+
5158
/// Reads a boolean value from persistent storage under the specified app group.
5259
///
5360
/// If the persistent storage does not contains [key], then [null] will be returned

0 commit comments

Comments
 (0)