Flutter iOS Embedder
FlutterPlatformPlugin Class Reference

#import <FlutterPlatformPlugin.h>

Inheritance diagram for FlutterPlatformPlugin:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 
(instancetype) - initWithEngine:
 
(void) - handleMethodCall:result:
 
(void) - showShareViewController:
 
(void) - searchWeb:
 
(void) - showLookUpViewController:
 

Class Methods

(instancetype) + NS_UNAVAILABLE
 

Detailed Description

Definition at line 11 of file FlutterPlatformPlugin.h.

Method Documentation

◆ handleMethodCall:result:

- (void) handleMethodCall: (FlutterMethodCall*)  call
result: (FlutterResult result 

Definition at line 81 of file FlutterPlatformPlugin.mm.

107  :(FlutterMethodCall*)call result:(FlutterResult)result {
108  NSString* method = call.method;
109  id args = call.arguments;
110  if ([method isEqualToString:@"SystemSound.play"]) {
111  [self playSystemSound:args];
112  result(nil);
113  } else if ([method isEqualToString:@"HapticFeedback.vibrate"]) {
114  [self vibrateHapticFeedback:args];
115  result(nil);
116  } else if ([method isEqualToString:@"SystemChrome.setPreferredOrientations"]) {
117  [self setSystemChromePreferredOrientations:args];
118  result(nil);
119  } else if ([method isEqualToString:@"SystemChrome.setApplicationSwitcherDescription"]) {
120  [self setSystemChromeApplicationSwitcherDescription:args];
121  result(nil);
122  } else if ([method isEqualToString:@"SystemChrome.setEnabledSystemUIOverlays"]) {
123  [self setSystemChromeEnabledSystemUIOverlays:args];
124  result(nil);
125  } else if ([method isEqualToString:@"SystemChrome.setEnabledSystemUIMode"]) {
126  [self setSystemChromeEnabledSystemUIMode:args];
127  result(nil);
128  } else if ([method isEqualToString:@"SystemChrome.restoreSystemUIOverlays"]) {
129  [self restoreSystemChromeSystemUIOverlays];
130  result(nil);
131  } else if ([method isEqualToString:@"SystemChrome.setSystemUIOverlayStyle"]) {
132  [self setSystemChromeSystemUIOverlayStyle:args];
133  result(nil);
134  } else if ([method isEqualToString:@"SystemNavigator.pop"]) {
135  NSNumber* isAnimated = args;
136  [self popSystemNavigator:isAnimated.boolValue];
137  result(nil);
138  } else if ([method isEqualToString:@"Clipboard.getData"]) {
139  result([self getClipboardData:args]);
140  } else if ([method isEqualToString:@"Clipboard.setData"]) {
141  [self setClipboardData:args];
142  result(nil);
143  } else if ([method isEqualToString:@"Clipboard.hasStrings"]) {
144  result([self clipboardHasStrings]);
145  } else if ([method isEqualToString:@"LiveText.isLiveTextInputAvailable"]) {
146  result(@([self isLiveTextInputAvailable]));
147  } else if ([method isEqualToString:@"SearchWeb.invoke"]) {
148  [self searchWeb:args];
149  result(nil);
150  } else if ([method isEqualToString:@"LookUp.invoke"]) {
151  [self showLookUpViewController:args];
152  result(nil);
153  } else if ([method isEqualToString:@"Share.invoke"]) {
154  [self showShareViewController:args];
155  result(nil);
156  } else if ([method isEqualToString:@"ContextMenu.showSystemContextMenu"]) {
157  [self showSystemContextMenu:args];
158  result(nil);
159  } else if ([method isEqualToString:@"ContextMenu.hideSystemContextMenu"]) {
160  [self hideSystemContextMenu];
161  result(nil);
162  } else {
164  }
165 }
void(^ FlutterResult)(id _Nullable result)
FLUTTER_DARWIN_EXPORT NSObject const * FlutterMethodNotImplemented

References engine.

◆ initWithEngine:

- (instancetype) initWithEngine: (FlutterEngine*)  NS_DESIGNATED_INITIALIZER

Definition at line 81 of file FlutterPlatformPlugin.mm.

87  FML_DCHECK(engine) << "engine must be set";
88  self = [super init];
89 
90  if (self) {
91  _engine = engine;
92  NSObject* infoValue = [[NSBundle mainBundle]
93  objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"];
94 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
95  if (infoValue != nil && ![infoValue isKindOfClass:[NSNumber class]]) {
96  FML_LOG(ERROR) << "The value of UIViewControllerBasedStatusBarAppearance in info.plist must "
97  "be a Boolean type.";
98  }
99 #endif
100  _enableViewControllerBasedStatusBarAppearance =
101  (infoValue == nil || [(NSNumber*)infoValue boolValue]);
102  }
103 
104  return self;
105 }

◆ NS_UNAVAILABLE [1/2]

+ (instancetype) NS_UNAVAILABLE

◆ NS_UNAVAILABLE [2/2]

- (instancetype) NS_UNAVAILABLE

◆ searchWeb:

- (void) searchWeb: (NSString*)  searchTerm

Definition at line 81 of file FlutterPlatformPlugin.mm.

223  :(NSString*)searchTerm {
224  UIApplication* flutterApplication = FlutterSharedApplication.application;
225  if (flutterApplication == nil) {
226  FML_LOG(WARNING) << "SearchWeb.invoke is not availabe in app extension.";
227  return;
228  }
229 
230  NSString* escapedText = [searchTerm
231  stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet
232  URLHostAllowedCharacterSet]];
233  NSString* searchURL = [NSString stringWithFormat:@"%@%@", kSearchURLPrefix, escapedText];
234 
235  [flutterApplication openURL:[NSURL URLWithString:searchURL] options:@{} completionHandler:nil];
236 }

◆ showLookUpViewController:

- (void) showLookUpViewController: (NSString*)  term

Definition at line 81 of file FlutterPlatformPlugin.mm.

432  :(NSString*)term {
433  UIViewController* engineViewController = [self.engine viewController];
434  UIReferenceLibraryViewController* referenceLibraryViewController =
435  [[UIReferenceLibraryViewController alloc] initWithTerm:term];
436  [engineViewController presentViewController:referenceLibraryViewController
437  animated:YES
438  completion:nil];
439 }

◆ showShareViewController:

- (void) showShareViewController: (NSString*)  content

Definition at line 81 of file FlutterPlatformPlugin.mm.

186  :(NSString*)content {
187  UIViewController* engineViewController = [self.engine viewController];
188 
189  NSArray* itemsToShare = @[ content ?: [NSNull null] ];
190  UIActivityViewController* activityViewController =
191  [[UIActivityViewController alloc] initWithActivityItems:itemsToShare
192  applicationActivities:nil];
193 
194  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
195  // On iPad, the share screen is presented in a popover view, and requires a
196  // sourceView and sourceRect
197  FlutterTextInputPlugin* _textInputPlugin = [self.engine textInputPlugin];
198  UITextRange* range = _textInputPlugin.textInputView.selectedTextRange;
199 
200  // firstRectForRange cannot be used here as it's current implementation does
201  // not always return the full rect of the range.
202  CGRect firstRect = [(FlutterTextInputView*)_textInputPlugin.textInputView
203  caretRectForPosition:(FlutterTextPosition*)range.start];
204  CGRect transformedFirstRect = [(FlutterTextInputView*)_textInputPlugin.textInputView
205  localRectFromFrameworkTransform:firstRect];
206  CGRect lastRect = [(FlutterTextInputView*)_textInputPlugin.textInputView
207  caretRectForPosition:(FlutterTextPosition*)range.end];
208  CGRect transformedLastRect = [(FlutterTextInputView*)_textInputPlugin.textInputView
209  localRectFromFrameworkTransform:lastRect];
210 
211  activityViewController.popoverPresentationController.sourceView = engineViewController.view;
212  // In case of RTL Language, get the minimum x coordinate
213  activityViewController.popoverPresentationController.sourceRect =
214  CGRectMake(fmin(transformedFirstRect.origin.x, transformedLastRect.origin.x),
215  transformedFirstRect.origin.y,
216  abs(transformedLastRect.origin.x - transformedFirstRect.origin.x),
217  transformedFirstRect.size.height);
218  }
219 
220  [engineViewController presentViewController:activityViewController animated:YES completion:nil];
221 }
UIView< UITextInput > * textInputView()

The documentation for this class was generated from the following files: