diff --git a/packages/flutter_tools/templates/plugin/linux.tmpl/projectName_plugin.cc.tmpl b/packages/flutter_tools/templates/plugin/linux.tmpl/projectName_plugin.cc.tmpl index aab588b64b..5a0822a16a 100644 --- a/packages/flutter_tools/templates/plugin/linux.tmpl/projectName_plugin.cc.tmpl +++ b/packages/flutter_tools/templates/plugin/linux.tmpl/projectName_plugin.cc.tmpl @@ -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>; - auto insert_result = plugin_registrars->emplace( - registrar, std::make_unique(registrar)); - - {{pluginClass}}::RegisterWithRegistrar(insert_result.first->second.get()); + {{pluginClass}}::RegisterWithRegistrar( + flutter::PluginRegistrarManager::GetInstance() + ->GetRegistrar(registrar)); } diff --git a/packages/flutter_tools/templates/plugin/windows.tmpl/projectName_plugin.cpp.tmpl b/packages/flutter_tools/templates/plugin/windows.tmpl/projectName_plugin.cpp.tmpl index a26aee4e4d..665c9169a2 100644 --- a/packages/flutter_tools/templates/plugin/windows.tmpl/projectName_plugin.cpp.tmpl +++ b/packages/flutter_tools/templates/plugin/windows.tmpl/projectName_plugin.cpp.tmpl @@ -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>; - auto insert_result = plugin_registrars->emplace( - registrar, std::make_unique(registrar)); - - {{pluginClass}}::RegisterWithRegistrar(insert_result.first->second.get()); + {{pluginClass}}::RegisterWithRegistrar( + flutter::PluginRegistrarManager::GetInstance() + ->GetRegistrar(registrar)); }