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

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

Referenced by 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 796 of file fl_view.cc.

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

Referenced by 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 763 of file fl_view.cc.

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

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

777 {
778 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
779
780 self->engine = FL_ENGINE(g_object_ref(engine));
781
782 self->view_id = fl_engine_add_view(engine, FL_RENDERABLE(self), 1, 1, 1.0,
783 self->cancellable, view_added_cb, self);
784
785 setup_engine(self);
786
787 return self;
788 }
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:892
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(), setup_engine(), and view_added_cb().

Referenced by 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 801 of file fl_view.cc.

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