232 exitType:(FlutterAppExitType)
type
234 _shouldTerminate = YES;
236
237
238 type = kFlutterAppExitTypeRequired;
239 }
241 case kFlutterAppExitTypeCancelable: {
245 [_engine sendOnChannel:kFlutterPlatformChannel
247 binaryReply:^(NSData* _Nullable reply) {
248 NSAssert(_terminator, @"terminator shouldn't be nil");
250 if ([decoded_reply isKindOfClass:[
FlutterError class]]) {
252 NSLog(@"Method call returned error[%@]: %@ %@", [error code], [error message],
253 [error details]);
254 _terminator(sender);
255 return;
256 }
257 if (![decoded_reply isKindOfClass:[NSDictionary class]]) {
258 NSLog(@"Call to System.requestAppExit returned an unexpected object: %@",
259 decoded_reply);
260 _terminator(sender);
261 return;
262 }
263 NSDictionary* replyArgs = (NSDictionary*)decoded_reply;
264 if ([replyArgs[@"response"] isEqual:@"exit"]) {
265 _terminator(sender);
266 } else if ([replyArgs[@"response"] isEqual:@"cancel"]) {
267 _shouldTerminate = NO;
268 }
269 if (result != nil) {
270 result(replyArgs);
271 }
272 }];
273 break;
274 }
275 case kFlutterAppExitTypeRequired:
276 NSAssert(
_terminator,
@"terminator shouldn't be nil");
278 break;
279 }
280}
NSData * encodeMethodCall:(FlutterMethodCall *call)
id decodeEnvelope:(NSData *envelope)
instancetype sharedInstance()
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)