Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions shell/platform/linux/fl_dart_project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<std::string> env_switches = flutter::GetSwitchesFromEnvironment();
Expand Down
6 changes: 6 additions & 0 deletions shell/platform/linux/fl_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<const char* const*>(dart_entrypoint_args);

if (FlutterEngineRunsAOTCompiledDartCode()) {
FlutterEngineAOTDataSource source = {};
Expand Down
24 changes: 24 additions & 0 deletions shell/platform/linux/public/flutter_linux/fl_dart_project.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_