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(
void {{pluginClass}}RegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar) {
// The plugin registrar wrappers owns the plugins, registered callbacks, etc.,
// so must remain valid for the life of the application.
static auto *plugin_registrars =
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());
{{pluginClass}}::RegisterWithRegistrar(
flutter::PluginRegistrarManager::GetInstance()
->GetRegistrar<flutter::PluginRegistrarGlfw>(registrar));
}
......@@ -83,13 +83,7 @@ void {{pluginClass}}::HandleMethodCall(
void {{pluginClass}}RegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar) {
// The plugin registrar wrappers owns the plugins, registered callbacks, etc.,
// so must remain valid for the life of the application.
static auto *plugin_registrars =
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());
{{pluginClass}}::RegisterWithRegistrar(
flutter::PluginRegistrarManager::GetInstance()
->GetRegistrar<flutter::PluginRegistrarWindows>(registrar));
}
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