Unverified Commit b429e7eb authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Update Windows and Linux plugin templates (#53876)

Updates Windows and Linux templates to use the new PluginRegistrarManager, improving lifetime handling and reducing boilerplate.
parent b0492cc9
...@@ -72,13 +72,7 @@ void {{pluginClass}}::HandleMethodCall( ...@@ -72,13 +72,7 @@ void {{pluginClass}}::HandleMethodCall(
void {{pluginClass}}RegisterWithRegistrar( void {{pluginClass}}RegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar) { FlutterDesktopPluginRegistrarRef registrar) {
// The plugin registrar wrappers owns the plugins, registered callbacks, etc., {{pluginClass}}::RegisterWithRegistrar(
// so must remain valid for the life of the application. flutter::PluginRegistrarManager::GetInstance()
static auto *plugin_registrars = ->GetRegistrar<flutter::PluginRegistrarGlfw>(registrar));
new std::map<FlutterDesktopPluginRegistrarRef,
std::unique_ptr<flutter::PluginRegistrarGlfw>>;
auto insert_result = plugin_registrars->emplace(
registrar, std::make_unique<flutter::PluginRegistrarGlfw>(registrar));
{{pluginClass}}::RegisterWithRegistrar(insert_result.first->second.get());
} }
...@@ -83,13 +83,7 @@ void {{pluginClass}}::HandleMethodCall( ...@@ -83,13 +83,7 @@ void {{pluginClass}}::HandleMethodCall(
void {{pluginClass}}RegisterWithRegistrar( void {{pluginClass}}RegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar) { FlutterDesktopPluginRegistrarRef registrar) {
// The plugin registrar wrappers owns the plugins, registered callbacks, etc., {{pluginClass}}::RegisterWithRegistrar(
// so must remain valid for the life of the application. flutter::PluginRegistrarManager::GetInstance()
static auto *plugin_registrars = ->GetRegistrar<flutter::PluginRegistrarWindows>(registrar));
new std::map<FlutterDesktopPluginRegistrarRef,
std::unique_ptr<flutter::PluginRegistrarWindows>>;
auto insert_result = plugin_registrars->emplace(
registrar, std::make_unique<flutter::PluginRegistrarWindows>(registrar));
{{pluginClass}}::RegisterWithRegistrar(insert_result.first->second.get());
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment