Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,19 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject<FlutterPluginRegistry>*
* @param result A callback for submitting the result of the call.
*/
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
@optional
/**
* Called when a plugin is being removed from a `FlutterEngine`, which is
* usually the result of the `FlutterEngine` being deallocated. This method
* provides the opportunity to do necessary cleanup.
*
* You will only receive this method if you registered your plugin instance with
* the `FlutterEngine` via `-[FlutterPluginRegistry publish:]`.
*
* @param registrar The registrar that was used to publish the plugin.
*
*/
- (void)detachFromEngineForRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar;
@end

#pragma mark -
Expand Down
7 changes: 7 additions & 0 deletions shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ - (instancetype)initWithName:(NSString*)labelPrefix
}

- (void)dealloc {
[_pluginPublications enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL* stop) {
if ([object respondsToSelector:@selector(detachFromEngineForRegistrar:)]) {
NSObject<FlutterPluginRegistrar>* registrar = [self registrarForPlugin:key];
[object detachFromEngineForRegistrar:registrar];
}
}];

[_labelPrefix release];
[_pluginPublications release];
_binaryMessenger.parent = nil;
Expand Down