Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit be1a37a

Browse files
committed
Implement Clipboard hasStrings method on iOS
1 parent 8825f91 commit be1a37a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
8888
} else if ([method isEqualToString:@"Clipboard.setData"]) {
8989
[self setClipboardData:args];
9090
result(nil);
91+
} else if ([method isEqualToString:@"Clipboard.hasStrings"]) {
92+
result([self clipboardHasStrings]);
9193
} else {
9294
result(FlutterMethodNotImplemented);
9395
}
@@ -248,4 +250,16 @@ - (void)setClipboardData:(NSDictionary*)data {
248250
}
249251
}
250252

253+
- (NSDictionary*)clipboardHasStrings {
254+
bool hasStrings = false;
255+
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
256+
if (@available(iOS 10, *)) {
257+
hasStrings = pasteboard.hasStrings;
258+
} else {
259+
NSString* stringInPasteboard = pasteboard.string;
260+
hasStrings = stringInPasteboard != nil;
261+
}
262+
return @{@"value" : @(hasStrings)};
263+
}
264+
251265
@end

0 commit comments

Comments
 (0)