mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
An app can now be:
```c
#include <flutter_linux/flutter_linux.h>
#include "flutter/generated_plugin_registrant.h"
static void register_plugins_cb(FlApplication *app, FlPluginRegistry *registry) {
fl_register_plugins(registry);
}
static GtkWindow *create_window_cb(FlApplication *app, FlView *view) {
GtkApplicationWindow *window =
GTK_APPLICATION_WINDOW(gtk_application_window_new(GTK_APPLICATION(app)));
gtk_window_set_title(GTK_WINDOW(window), "flutter_application_test");
gtk_window_set_default_size(GTK_WINDOW(window), 1280, 720);
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
return GTK_WINDOW(window);
}
int main(int argc, char** argv) {
g_autoptr(FlApplication) app = fl_application_new(APPLICATION_ID, G_APPLICATION_NON_UNIQUE);
g_signal_connect(app, "register-plugins", G_CALLBACK(register_plugins_cb), nullptr);
g_signal_connect(app, "create-window", G_CALLBACK(create_window_cb), nullptr);
return g_application_run(G_APPLICATION(app), argc, argv);
}
```
With this simplified, we can now build multi-window behaviour without having to modify the template much in the future.
Fixes https://github.com/flutter/flutter/issues/142920