diff --git a/shell/platform/linux/fl_dart_project.cc b/shell/platform/linux/fl_dart_project.cc index b9c0b3623f9f6..25551c72403f9 100644 --- a/shell/platform/linux/fl_dart_project.cc +++ b/shell/platform/linux/fl_dart_project.cc @@ -19,6 +19,7 @@ struct _FlDartProject { gchar* aot_library_path; gchar* assets_path; gchar* icu_data_path; + gchar** dart_entrypoint_args; }; G_DEFINE_TYPE(FlDartProject, fl_dart_project, G_TYPE_OBJECT) @@ -42,6 +43,7 @@ static void fl_dart_project_dispose(GObject* object) { g_clear_pointer(&self->aot_library_path, g_free); g_clear_pointer(&self->assets_path, g_free); g_clear_pointer(&self->icu_data_path, g_free); + g_clear_pointer(&self->dart_entrypoint_args, g_strfreev); G_OBJECT_CLASS(fl_dart_project_parent_class)->dispose(object); } @@ -98,6 +100,20 @@ G_MODULE_EXPORT const gchar* fl_dart_project_get_icu_data_path( return self->icu_data_path; } +G_MODULE_EXPORT gchar** fl_dart_project_get_dart_entrypoint_arguments( + FlDartProject* self) { + g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr); + return self->dart_entrypoint_args; +} + +G_MODULE_EXPORT void fl_dart_project_set_dart_entrypoint_arguments( + FlDartProject* self, + char** argv) { + g_return_if_fail(FL_IS_DART_PROJECT(self)); + g_clear_pointer(&self->dart_entrypoint_args, g_strfreev); + self->dart_entrypoint_args = g_strdupv(argv); +} + GPtrArray* fl_dart_project_get_switches(FlDartProject* self) { GPtrArray* switches = g_ptr_array_new_with_free_func(g_free); std::vector env_switches = flutter::GetSwitchesFromEnvironment(); diff --git a/shell/platform/linux/fl_engine.cc b/shell/platform/linux/fl_engine.cc index e9cb23a749d59..6a53f91442017 100644 --- a/shell/platform/linux/fl_engine.cc +++ b/shell/platform/linux/fl_engine.cc @@ -381,6 +381,9 @@ gboolean fl_engine_start(FlEngine* self, GError** error) { // so that all switches are used. g_ptr_array_insert(command_line_args, 0, g_strdup("flutter")); + gchar** dart_entrypoint_args = + fl_dart_project_get_dart_entrypoint_arguments(self->project); + FlutterProjectArgs args = {}; args.struct_size = sizeof(FlutterProjectArgs); args.assets_path = fl_dart_project_get_assets_path(self->project); @@ -391,6 +394,9 @@ gboolean fl_engine_start(FlEngine* self, GError** error) { args.platform_message_callback = fl_engine_platform_message_cb; args.custom_task_runners = &custom_task_runners; args.shutdown_dart_vm_when_done = true; + args.dart_entrypoint_argc = g_strv_length(dart_entrypoint_args); + args.dart_entrypoint_argv = + reinterpret_cast(dart_entrypoint_args); if (FlutterEngineRunsAOTCompiledDartCode()) { FlutterEngineAOTDataSource source = {}; diff --git a/shell/platform/linux/public/flutter_linux/fl_dart_project.h b/shell/platform/linux/public/flutter_linux/fl_dart_project.h index 3a0e91f245133..1b56e24c32627 100644 --- a/shell/platform/linux/public/flutter_linux/fl_dart_project.h +++ b/shell/platform/linux/public/flutter_linux/fl_dart_project.h @@ -96,6 +96,30 @@ const gchar* fl_dart_project_get_assets_path(FlDartProject* project); */ const gchar* fl_dart_project_get_icu_data_path(FlDartProject* project); +/** + * fl_dart_project_set_dart_entrypoint_arguments: + * @project: an #FlDartProject. + * @argv: a pointer to a NULL-terminated array of C strings containing the + * command line arguments. + * + * Sets the command line arguments to be passed through to the Dart + * entrypoint function. + */ +void fl_dart_project_set_dart_entrypoint_arguments(FlDartProject* project, + char** argv); + +/** + * fl_dart_project_get_dart_entrypoint_arguments: + * @project: an #FlDartProject. + * + * Gets the command line arguments to be passed through to the Dart entrypoint + * function. + * + * Returns: a NULL-terminated array of strings containing the command line + * arguments to be passed to the Dart entrypoint. + */ +gchar** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject* project); + G_END_DECLS #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_DART_PROJECT_H_