@@ -173,6 +173,14 @@ - (NSDictionary*)getClipboardData:(NSString*)format;
173173 */
174174- (void )setClipboardData : (NSDictionary *)data ;
175175
176+ /* *
177+ * Returns true iff the clipboard contains nonempty string data.
178+ *
179+ * See also:
180+ * * https://developer.apple.com/documentation/uikit/uipasteboard/1829416-hasstrings
181+ */
182+ - (NSDictionary *)clipboardHasStrings ;
183+
176184@end
177185
178186#pragma mark - FlutterViewController implementation.
@@ -505,6 +513,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
505513 } else if ([call.method isEqualToString: @" Clipboard.setData" ]) {
506514 [self setClipboardData: call.arguments];
507515 result (nil );
516+ } else if ([call.method isEqualToString: @" Clipboard.hasStrings" ]) {
517+ result ([self clipboardHasStrings ]);
508518 } else {
509519 result (FlutterMethodNotImplemented);
510520 }
@@ -527,13 +537,24 @@ - (NSDictionary*)getClipboardData:(NSString*)format {
527537
528538- (void )setClipboardData : (NSDictionary *)data {
529539 NSPasteboard * pasteboard = [NSPasteboard generalPasteboard ];
530- NSString * text = data[@" text" ];
540+ NSString * text = data[@" text" ];
531541 if (text && ![text isEqual: [NSNull null ]]) {
532542 [pasteboard clearContents ];
533543 [pasteboard setString: text forType: NSPasteboardTypeString ];
534544 }
535545}
536546
547+ - (NSDictionary *)clipboardHasStrings {
548+ NSDictionary * data = [self getClipboardData: [NSString stringWithFormat: @" %s " , kTextPlainFormat ]];
549+ NSString * string = data[@" text" ];
550+ BOOL hasStrings = string.length > 0 ;
551+ return @{@" value" : @(hasStrings)};
552+ /*
553+ UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
554+ return @{@"value" : @(pasteboard.hasStrings)};
555+ */
556+ }
557+
537558#pragma mark - FlutterViewReshapeListener
538559
539560/* *
0 commit comments