@@ -182,9 +182,10 @@ std::weak_ptr<DartIsolate> DartIsolate::CreateRunningRootIsolate(
182182 settings.root_isolate_create_callback (*isolate.get ());
183183 }
184184
185- if (!isolate->RunFromLibrary (dart_entrypoint_library, //
186- dart_entrypoint, //
187- settings.dart_entrypoint_args //
185+ if (!isolate->RunFromLibrary (dart_entrypoint_library, //
186+ dart_entrypoint, //
187+ settings.dart_entrypoint_args , //
188+ settings.enable_dart_plugin_registrant //
188189 )) {
189190 FML_LOG (ERROR) << " Could not run the run main Dart entrypoint." ;
190191 return {};
@@ -703,7 +704,8 @@ bool DartIsolate::MarkIsolateRunnable() {
703704
704705bool DartIsolate::RunFromLibrary (std::optional<std::string> library_name,
705706 std::optional<std::string> entrypoint,
706- const std::vector<std::string>& args) {
707+ const std::vector<std::string>& args,
708+ bool enable_dart_plugin_registrant) {
707709 TRACE_EVENT0 (" flutter" , " DartIsolate::RunFromLibrary" );
708710 if (phase_ != Phase::Ready) {
709711 return false ;
@@ -737,14 +739,13 @@ bool DartIsolate::RunFromLibrary(std::optional<std::string> library_name,
737739 // as usual.
738740 //
739741 // This allows embeddings to change the name of the entrypoint function.
740- auto plugin_registrant_function =
741- ::Dart_GetField (library_handle, tonic::ToDart(" _registerPlugins" ));
742-
743- if (Dart_IsError (plugin_registrant_function)) {
744- plugin_registrant_function = Dart_Null ();
745- FML_DLOG (ERROR) << " plugin_registrant_function IS NULL " ;
746- } else {
747- FML_DLOG (ERROR) << " plugin_registrant_function IS NOT NULL " ;
742+ auto plugin_registrant_function = Dart_Null ();
743+ if (enable_dart_plugin_registrant) {
744+ auto defined_plugin_registrant_function =
745+ ::Dart_GetField (library_handle, tonic::ToDart(" _registerPlugins" ));
746+ if (!Dart_IsError (defined_plugin_registrant_function)) {
747+ plugin_registrant_function = defined_plugin_registrant_function;
748+ }
748749 }
749750
750751 if (!InvokeMainEntrypoint (user_entrypoint_function,
0 commit comments