| Flutter Linux Embedder |

Functions
fl_view.h File Reference
`#include <gmodule.h>`
`#include <gtk/gtk.h>`
`#include "fl_dart_project.h"`
`#include "fl_engine.h"`

Go to the source code of this file.

## Functions
G_BEGIN_DECLS G_MODULE_EXPORT FlView * | fl_view_new (FlDartProject *project)
FlView * | fl_view_new_for_engine (FlEngine *engine)
FlEngine * | fl_view_get_engine (FlView *view)
int64_t | fl_view_get_id (FlView *view)
void | fl_view_set_background_color (FlView *view, const GdkRGBA *color)

## Function Documentation

## ◆ fl_view_get_engine()

FlEngine* fl_view_get_engine | ( | FlView * | view | ) |

fl_view_get_engine: @view: an #FlView.

Gets the engine being rendered in the view.

Returns: an #FlEngine.

Definition at line 787 of file fl_view.cc.

787 {
788 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
789 return self->engine;
790 }

Referenced by fl_application_activate(), and TEST().

## ◆ fl_view_get_id()

int64_t fl_view_get_id | ( | FlView * | view | ) |

fl_view_get_id: @view: an #FlView.

Gets the Flutter view ID used by this view.

Returns: a view ID or -1 if now ID assigned.

Definition at line 793 of file fl_view.cc.

793 {
794 g_return_val_if_fail(FL_IS_VIEW(self), -1);
795 return self->view_id;
796 }

Referenced by create_regular(), and TEST().

## ◆ fl_view_new()

G_BEGIN_DECLS G_MODULE_EXPORT FlView* fl_view_new | ( | FlDartProject * | project | ) |

FlView:

#FlView is a GTK widget that is capable of displaying a Flutter application.

The following example shows how to set up a view in a GTK application: |[ FlDartProject *project = fl_dart_project_new (); FlView *view = fl_view_new (project); gtk_widget_show (GTK_WIDGET (view)); gtk_container_add (GTK_CONTAINER (parent), view);

FlBinaryMessenger *messenger = fl_engine_get_binary_messenger (fl_view_get_engine (view)); setup_channels_or_plugins (messenger); ]| fl_view_new: @project: The project to show.

Creates a widget to show a Flutter application.

Returns: a new #FlView.

Definition at line 751 of file fl_view.cc.

751 {
752 g_autoptr(FlEngine) engine = fl_engine_new(project);
753 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
754
755 self->view_id = flutter::kFlutterImplicitViewId;
756 self->engine = FL_ENGINE(g_object_ref(engine));
757
758 setup_engine(self);
759
760 g_signal_connect_swapped(self->gl_area, "create-context",
761 G_CALLBACK(create_context_cb), self);
762 g_signal_connect_swapped(self->gl_area, "realize", G_CALLBACK(realize_cb),
763 self);
764 g_signal_connect_swapped(self->gl_area, "unrealize", G_CALLBACK(unrealize_cb),
765 self);
766
767 fl_engine_set_implicit_view(engine, FL_RENDERABLE(self));
768
769 return self;
770 }
fl_engine_set_implicit_view
void fl_engine_set_implicit_view(FlEngine *self, FlRenderable *renderable)
Definition: fl_engine.cc:743
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:584
setup_engine
static void setup_engine(FlView *self)
Definition: fl_view.cc:676
create_context_cb
static GdkGLContext * create_context_cb(FlView *self)
Definition: fl_view.cc:440
realize_cb
static void realize_cb(FlView *self)
Definition: fl_view.cc:457
unrealize_cb
static void unrealize_cb(FlView *self)
Definition: fl_view.cc:515

References create_context_cb(), fl_engine_new(), fl_engine_set_implicit_view(), realize_cb(), setup_engine(), and unrealize_cb().

Referenced by fl_application_activate(), and TEST().

## ◆ fl_view_new_for_engine()

FlView* fl_view_new_for_engine | ( | FlEngine * | engine | ) |

fl_view_new_for_engine: @engine: an #FlEngine.

Creates a widget to show a window in a Flutter application. The engine must be not be headless.

Returns: a new #FlView.

Definition at line 772 of file fl_view.cc.

772 {
773 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
774
775 self->engine = FL_ENGINE(g_object_ref(engine));
776
777 self->view_id = fl_engine_add_view(engine, FL_RENDERABLE(self), 1, 1, 1.0,
778 self->cancellable, view_added_cb, self);
779
780 setup_engine(self);
781
782 g_signal_connect_swapped(self->gl_area, "realize",
783 G_CALLBACK(secondary_realize_cb), self);
784 return self;
785 }
fl_engine_add_view
FlutterViewId fl_engine_add_view(FlEngine *self, FlRenderable *renderable, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:750
secondary_realize_cb
static void secondary_realize_cb(FlView *self)
Definition: fl_view.cc:495
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:204

References fl_engine_add_view(), secondary_realize_cb(), setup_engine(), and view_added_cb().

Referenced by create_regular(), and TEST().

## ◆ fl_view_set_background_color()

void fl_view_set_background_color | ( | FlView * | view,
|  | const GdkRGBA * | color
| ) |  |

fl_view_set_background_color: @view: an #FlView. @color: a background color.

Set the background color for Flutter (defaults to black).

Definition at line 798 of file fl_view.cc.

799 {
800 g_return_if_fail(FL_IS_VIEW(self));
801 gdk_rgba_free(self->background_color);
802 self->background_color = gdk_rgba_copy(color);
803 }