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

838 {
839 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
840 return self->engine;
841 }

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

844 {
845 g_return_val_if_fail(FL_IS_VIEW(self), -1);
846 return self->view_id;
847 }

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

811 {
812 g_autoptr(FlEngine) engine = fl_engine_new(project);
813 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
814
815 self->view_id = flutter::kFlutterImplicitViewId;
816 self->engine = FL_ENGINE(g_object_ref(engine));
817
818 setup_engine(self);
819
820 fl_engine_set_implicit_view(engine, FL_RENDERABLE(self));
821
822 return self;
823 }
fl_engine_set_implicit_view
void fl_engine_set_implicit_view(FlEngine *self, FlRenderable *renderable)
Definition: fl_engine.cc:875
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:691
setup_engine
static void setup_engine(FlView *self)
Definition: fl_view.cc:711

References fl_engine_new(), fl_engine_set_implicit_view(), 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 825 of file fl_view.cc.

825 {
826 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
827
828 self->engine = FL_ENGINE(g_object_ref(engine));
829
830 self->view_id = fl_engine_add_view(engine, FL_RENDERABLE(self), 1, 1, 1.0,
831 self->cancellable, view_added_cb, self);
832
833 setup_engine(self);
834
835 return self;
836 }
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:882
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:216

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

850 {
851 g_return_if_fail(FL_IS_VIEW(self));
852 gdk_rgba_free(self->background_color);
853 self->background_color = gdk_rgba_copy(color);
854 }