| 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 788 of file fl_view.cc.

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

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 794 of file fl_view.cc.

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

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 761 of file fl_view.cc.

761 {
762 g_autoptr(FlEngine) engine = fl_engine_new(project);
763 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
764
765 self->view_id = flutter::kFlutterImplicitViewId;
766 self->engine = FL_ENGINE(g_object_ref(engine));
767
768 setup_engine(self);
769
770 fl_engine_set_implicit_view(engine, FL_RENDERABLE(self));
771
772 return self;
773 }
g_autoptr
g_autoptr(GMutexLocker) locker
fl_engine_set_implicit_view
void fl_engine_set_implicit_view(FlEngine *self, FlRenderable *renderable)
Definition: fl_engine.cc:876
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:692
setup_engine
static void setup_engine(FlView *self)
Definition: fl_view.cc:682

References fl_engine_new(), fl_engine_set_implicit_view(), g_autoptr(), and setup_engine().

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 775 of file fl_view.cc.

775 {
776 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
777
778 self->engine = FL_ENGINE(g_object_ref(engine));
779
780 self->view_id = fl_engine_add_view(engine, FL_RENDERABLE(self), 1, 1, 1.0,
781 self->cancellable, view_added_cb, self);
782
783 setup_engine(self);
784
785 return self;
786 }
self
g_cond_signal & self
Definition: fl_compositor_software.cc:67
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:883
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:207

References fl_engine_add_view(), self, 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 799 of file fl_view.cc.

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

References self.