Skip to content

Commit

Permalink
feat: support Uint8List as FlutterStandardTypedData on iOS (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
bierbaumtim committed Mar 8, 2024
1 parent e5d1dc7 commit cba8262
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/integration_test/ios_test.dart
Expand Up @@ -23,6 +23,7 @@ void main() {
'boolKey': true,
'floatingNumberKey': 12.1,
'nullValueKey': null,
'uint8ListKey': Uint8List.fromList([]),
};

const defaultValue = MapEntry('defaultKey', 'defaultValue');
Expand Down
6 changes: 5 additions & 1 deletion ios/Classes/SwiftHomeWidgetPlugin.swift
Expand Up @@ -63,7 +63,11 @@ public class SwiftHomeWidgetPlugin: NSObject, FlutterPlugin, FlutterStreamHandle
{
let preferences = UserDefaults.init(suiteName: SwiftHomeWidgetPlugin.groupId)
if data != nil {
preferences?.setValue(data, forKey: id)
if let binaryData = data as? FlutterStandardTypedData {
preferences?.setValue(Data(binaryData.data), forKey: id)
} else {
preferences?.setValue(data, forKey: id)
}
} else {
preferences?.removeObject(forKey: id)
}
Expand Down

0 comments on commit cba8262

Please sign in to comment.