diff --git a/shell/platform/linux/fl_dart_project.cc b/shell/platform/linux/fl_dart_project.cc index ba65580db7e..480ba4d2f27 100644 --- a/shell/platform/linux/fl_dart_project.cc +++ b/shell/platform/linux/fl_dart_project.cc @@ -9,6 +9,7 @@ struct _FlDartProject { GObject parent_instance; + gboolean enable_mirrors; gchar* aot_library_path; gchar* assets_path; gchar* icu_data_path; @@ -60,6 +61,19 @@ G_MODULE_EXPORT FlDartProject* fl_dart_project_new() { return self; } +G_MODULE_EXPORT void fl_dart_project_set_enable_mirrors( + FlDartProject* self, + gboolean enable_mirrors) { + g_return_if_fail(FL_IS_DART_PROJECT(self)); + self->enable_mirrors = enable_mirrors; +} + +G_MODULE_EXPORT gboolean +fl_dart_project_get_enable_mirrors(FlDartProject* self) { + g_return_val_if_fail(FL_IS_DART_PROJECT(self), FALSE); + return self->enable_mirrors; +} + G_MODULE_EXPORT const gchar* fl_dart_project_get_aot_library_path( FlDartProject* self) { g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr); diff --git a/shell/platform/linux/fl_dart_project_test.cc b/shell/platform/linux/fl_dart_project_test.cc index d5728057025..cc89563d78a 100644 --- a/shell/platform/linux/fl_dart_project_test.cc +++ b/shell/platform/linux/fl_dart_project_test.cc @@ -24,3 +24,12 @@ TEST(FlDartProjectTest, GetPaths) { EXPECT_STREQ(fl_dart_project_get_icu_data_path(project), expected_icu_data_path); } + +TEST(FlDartProjectTest, EnableMirrors) { + g_autoptr(FlDartProject) project = fl_dart_project_new(); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + EXPECT_FALSE(fl_dart_project_get_enable_mirrors(project)); + fl_dart_project_set_enable_mirrors(project, TRUE); + EXPECT_TRUE(fl_dart_project_get_enable_mirrors(project)); + G_GNUC_END_IGNORE_DEPRECATIONS +} diff --git a/shell/platform/linux/fl_engine.cc b/shell/platform/linux/fl_engine.cc index dd292d5f3b1..fe399749cfc 100644 --- a/shell/platform/linux/fl_engine.cc +++ b/shell/platform/linux/fl_engine.cc @@ -274,10 +274,24 @@ gboolean fl_engine_start(FlEngine* self, GError** error) { custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners); custom_task_runners.platform_task_runner = &platform_task_runner; + g_autoptr(GPtrArray) command_line_args = + g_ptr_array_new_with_free_func(g_free); + g_ptr_array_add(command_line_args, g_strdup("flutter")); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + gboolean enable_mirrors = fl_dart_project_get_enable_mirrors(self->project); + G_GNUC_END_IGNORE_DEPRECATIONS + if (enable_mirrors) { + g_ptr_array_add(command_line_args, + g_strdup("--dart-flags=--enable_mirrors=true")); + } + FlutterProjectArgs args = {}; args.struct_size = sizeof(FlutterProjectArgs); args.assets_path = fl_dart_project_get_assets_path(self->project); args.icu_data_path = fl_dart_project_get_icu_data_path(self->project); + args.command_line_argc = command_line_args->len; + args.command_line_argv = + reinterpret_cast(command_line_args->pdata); args.platform_message_callback = fl_engine_platform_message_cb; args.custom_task_runners = &custom_task_runners; args.shutdown_dart_vm_when_done = true; 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 6c7e5ad5673..3a0e91f2451 100644 --- a/shell/platform/linux/public/flutter_linux/fl_dart_project.h +++ b/shell/platform/linux/public/flutter_linux/fl_dart_project.h @@ -35,6 +35,33 @@ G_DECLARE_FINAL_TYPE(FlDartProject, fl_dart_project, FL, DART_PROJECT, GObject) */ FlDartProject* fl_dart_project_new(); +/** + * fl_dart_project_set_enable_mirrors: + * @project: an #FlDartProject. + * @enable_mirrors: %TRUE if the dart:mirrors library should be used. + * + * Sets if this Flutter project can use the dart:mirrors library. + * + * Deprecated: This function is temporary and will be removed in a future + * release. + */ +void fl_dart_project_set_enable_mirrors(FlDartProject* project, + gboolean enable_mirrors) G_DEPRECATED; + +/** + * fl_dart_project_get_enable_mirrors: + * @project: an #FlDartProject. + * + * Gets if this Flutter project can use the dart:mirrors library. + * + * Returns: %TRUE if the dart:mirrors library can be used. + * + * Deprecated: This function is temporary and will be removed in a future + * release. + */ +gboolean fl_dart_project_get_enable_mirrors(FlDartProject* project) + G_DEPRECATED; + /** * fl_dart_project_get_aot_library_path: * @project: an #FlDartProject.