@@ -14,6 +14,12 @@ struct _MyApplication {
1414
1515G_DEFINE_TYPE (MyApplication, my_application, GTK_TYPE_APPLICATION)
1616
17+ // Called when first Flutter frame received.
18+ static void first_frame_cb(MyApplication* self, FlView *view)
19+ {
20+ gtk_widget_show (gtk_widget_get_toplevel (GTK_WIDGET (view)));
21+ }
22+
1723// Implements GApplication::activate.
1824static void my_application_activate (GApplication* application) {
1925 MyApplication* self = MY_APPLICATION (application);
@@ -48,15 +54,23 @@ static void my_application_activate(GApplication* application) {
4854 }
4955
5056 gtk_window_set_default_size (window, 1280 , 720 );
51- gtk_widget_show (GTK_WIDGET (window));
5257
5358 g_autoptr (FlDartProject) project = fl_dart_project_new ();
5459 fl_dart_project_set_dart_entrypoint_arguments (project, self->dart_entrypoint_arguments );
5560
5661 FlView* view = fl_view_new (project);
62+ GdkRGBA background_color;
63+ // Background defaults to black, override it here if necessary, e.g. #00000000 for transparent.
64+ gdk_rgba_parse (&background_color, " #000000" );
65+ fl_view_set_background_color (view, &background_color);
5766 gtk_widget_show (GTK_WIDGET (view));
5867 gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (view));
5968
69+ // Show the window when Flutter renders.
70+ // Requires the view to be realized so we can start rendering.
71+ g_signal_connect_swapped (view, " first-frame" , G_CALLBACK (first_frame_cb), self);
72+ gtk_widget_realize (GTK_WIDGET (view));
73+
6074 fl_register_plugins (FL_PLUGIN_REGISTRY (view));
6175
6276 gtk_widget_grab_focus (GTK_WIDGET (view));
0 commit comments