| Flutter Windows Embedder |

Public Member Functions | Friends | List of all members
flutter::FlutterEngine Class Reference

`#include <flutter_engine.h>`

Inheritance diagram for flutter::FlutterEngine:

## Public Member Functions
| FlutterEngine (const DartProject &project)
virtual | ~FlutterEngine ()
| FlutterEngine (FlutterEngine const &)=delete
FlutterEngine & | operator= (FlutterEngine const &)=delete
bool | Run ()
bool | Run (const char *entry_point)
void | ShutDown ()
std::chrono::nanoseconds | ProcessMessages ()
void | ReloadSystemFonts ()
void | ReloadPlatformBrightness ()
FlutterDesktopPluginRegistrarRef | GetRegistrarForPlugin (const std::string &plugin_name) override
BinaryMessenger * | messenger ()
void | SetNextFrameCallback (std::function< void()> callback)
std::optional< LRESULT > | ProcessExternalWindowMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
Public Member Functions inherited from flutter::PluginRegistry
| PluginRegistry ()=default
virtual | ~PluginRegistry ()=default
| PluginRegistry (PluginRegistry const &)=delete
PluginRegistry & | operator= (PluginRegistry const &)=delete

## Friends
class | FlutterViewController

## Detailed Description

Definition at line 28 of file flutter_engine.h.

## Constructor & Destructor Documentation

## ◆ FlutterEngine() [1/2]

flutter::FlutterEngine::FlutterEngine | ( | const DartProject & | project | ) |
| explicit

Definition at line 14 of file flutter_engine.cc.

14 {
15 FlutterDesktopEngineProperties c_engine_properties = {};
16 c_engine_properties.assets_path = project.assets_path().c_str();
17 c_engine_properties.icu_data_path = project.icu_data_path().c_str();
18 c_engine_properties.aot_library_path = project.aot_library_path().c_str();
19 c_engine_properties.dart_entrypoint = project.dart_entrypoint().c_str();
20
21 const std::vector<std::string>& entrypoint_args =
22 project.dart_entrypoint_arguments();
23 std::vector<const char*> entrypoint_argv;
24 std::transform(
25 entrypoint_args.begin(), entrypoint_args.end(),
26 std::back_inserter(entrypoint_argv),
27 [](const std::string& arg) -> const char* { return arg.c_str(); });
28
29 c_engine_properties.dart_entrypoint_argc =
30 static_cast<int>(entrypoint_argv.size());
31 c_engine_properties.dart_entrypoint_argv =
32 entrypoint_argv.empty() ? nullptr : entrypoint_argv.data();
33
34 engine_ = FlutterDesktopEngineCreate(&c_engine_properties);
35
36 auto core_messenger = FlutterDesktopEngineGetMessenger(engine_);
37 messenger_ = std::make_unique<BinaryMessengerImpl>(core_messenger);
38 }

References FlutterDesktopEngineProperties::aot_library_path, FlutterDesktopEngineProperties::assets_path, FlutterDesktopEngineProperties::dart_entrypoint, flutter::DartProject::dart_entrypoint(), FlutterDesktopEngineProperties::dart_entrypoint_argc, flutter::DartProject::dart_entrypoint_arguments(), FlutterDesktopEngineProperties::dart_entrypoint_argv, FlutterDesktopEngineCreate(), FlutterDesktopEngineGetMessenger(), and FlutterDesktopEngineProperties::icu_data_path.

## ◆ ~FlutterEngine()

flutter::FlutterEngine::~FlutterEngine | ( |  | ) |
| virtual

Definition at line 40 of file flutter_engine.cc.

40 {
41 ShutDown();
42 }

References ShutDown().

## ◆ FlutterEngine() [2/2]

flutter::FlutterEngine::FlutterEngine | ( | FlutterEngine const & |  | ) |
| delete

## Member Function Documentation

## ◆ GetRegistrarForPlugin()

FlutterDesktopPluginRegistrarRef flutter::FlutterEngine::GetRegistrarForPlugin | ( | const std::string & | plugin_name | ) |
| override virtual

Implements flutter::PluginRegistry.

Definition at line 80 of file flutter_engine.cc.

81 {
82 if (!engine_) {
83 std::cerr << "Cannot get plugin registrar on an engine that isn't running; "
84 "call Run first."
85 << std::endl;
86 return nullptr;
87 }
88 return FlutterDesktopEngineGetPluginRegistrar(engine_, plugin_name.c_str());
89 }

References FlutterDesktopEngineGetPluginRegistrar().

## ◆ messenger()

BinaryMessenger* flutter::FlutterEngine::messenger | ( |  | ) |
| inline

Definition at line 80 of file flutter_engine.h.

80 { return messenger_.get(); }

Referenced by flutter::TEST().

## ◆ operator=()

FlutterEngine& flutter::FlutterEngine::operator= | ( | FlutterEngine const & |  | ) |
| delete

## ◆ ProcessExternalWindowMessage()

std::optional< LRESULT > flutter::FlutterEngine::ProcessExternalWindowMessage | ( | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wparam,
|  | LPARAM | lparam
| ) |  |

Definition at line 103 of file flutter_engine.cc.

107 {
108 LRESULT result;
109 if (FlutterDesktopEngineProcessExternalWindowMessage(
110 engine_, hwnd, message, wparam, lparam, &result)) {
111 return result;
112 }
113 return std::nullopt;
114 }

References FlutterDesktopEngineProcessExternalWindowMessage(), and message.

Referenced by flutter::TEST().

## ◆ ProcessMessages()

std::chrono::nanoseconds flutter::FlutterEngine::ProcessMessages | ( |  | ) |

Definition at line 72 of file flutter_engine.cc.

72 {
73 return std::chrono::nanoseconds(FlutterDesktopEngineProcessMessages(engine_));
74 }

References FlutterDesktopEngineProcessMessages().

Referenced by flutter::TEST().

## ◆ ReloadPlatformBrightness()

void flutter::FlutterEngine::ReloadPlatformBrightness | ( |  | ) |

## ◆ ReloadSystemFonts()

void flutter::FlutterEngine::ReloadSystemFonts | ( |  | ) |

Definition at line 76 of file flutter_engine.cc.

76 {
77 FlutterDesktopEngineReloadSystemFonts(engine_);
78 }

References FlutterDesktopEngineReloadSystemFonts().

Referenced by flutter::TEST().

## ◆ Run() [1/2]

bool flutter::FlutterEngine::Run | ( |  | ) |

Definition at line 44 of file flutter_engine.cc.

44 {
45 return Run(nullptr);
46 }

Referenced by flutter::TEST(), and flutter::testing::TEST_F().

## ◆ Run() [2/2]

bool flutter::FlutterEngine::Run | ( | const char * | entry_point | ) |

Definition at line 48 of file flutter_engine.cc.

48 {
49 if (!engine_) {
50 std::cerr << "Cannot run an engine that failed creation." << std::endl;
51 return false;
52 }
53 if (has_been_run_) {
54 std::cerr << "Cannot run an engine more than once." << std::endl;
55 return false;
56 }
57 bool run_succeeded = FlutterDesktopEngineRun(engine_, entry_point);
58 if (!run_succeeded) {
59 std::cerr << "Failed to start engine." << std::endl;
60 }
61 has_been_run_ = true;
62 return run_succeeded;
63 }

References FlutterDesktopEngineRun().

## ◆ SetNextFrameCallback()

void flutter::FlutterEngine::SetNextFrameCallback | ( | std::function< void()> | callback | ) |

Definition at line 91 of file flutter_engine.cc.

91 {
92 next_frame_callback_ = std::move(callback);
93 FlutterDesktopEngineSetNextFrameCallback(
94 engine_,
95 [](void* user_data) {
96 FlutterEngine* self = static_cast<FlutterEngine*>(user_data);
97 self->next_frame_callback_();
98 self->next_frame_callback_ = nullptr;
99 },
100 this);
101 }

References callback, FlutterDesktopEngineSetNextFrameCallback(), and user_data.

Referenced by flutter::TEST().

## ◆ ShutDown()

void flutter::FlutterEngine::ShutDown | ( |  | ) |

Definition at line 65 of file flutter_engine.cc.

65 {
66 if (engine_ && owns_engine_) {
67 FlutterDesktopEngineDestroy(engine_);
68 }
69 engine_ = nullptr;
70 }

References FlutterDesktopEngineDestroy().

Referenced by flutter::TEST(), and ~FlutterEngine().

## Friends And Related Function Documentation

## ◆ FlutterViewController

friend class FlutterViewController
| friend

Definition at line 99 of file flutter_engine.h.

The documentation for this class was generated from the following files:

- shell/platform/windows/client_wrapper/include/flutter/flutter_engine.h
- shell/platform/windows/client_wrapper/flutter_engine.cc

FlutterDesktopEngineProperties::aot_library_path
const wchar_t * aot_library_path
Definition: flutter_windows.h:51
FlutterDesktopEngineGetMessenger
FlutterDesktopMessengerRef FlutterDesktopEngineGetMessenger(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:172
FlutterDesktopEngineProperties
Definition: flutter_windows.h:36
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:47
FlutterDesktopEngineProperties::dart_entrypoint_argv
const char ** dart_entrypoint_argv
Definition: flutter_windows.h:66
FlutterDesktopEngineProperties::icu_data_path
const wchar_t * icu_data_path
Definition: flutter_windows.h:45
FlutterDesktopEngineProcessExternalWindowMessage
bool FlutterDesktopEngineProcessExternalWindowMessage(FlutterDesktopEngineRef engine, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
Definition: flutter_windows.cc:210
FlutterDesktopEngineGetPluginRegistrar
FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar(FlutterDesktopEngineRef engine, const char *plugin_name)
Definition: flutter_windows.cc:162
FlutterDesktopEngineProperties::dart_entrypoint
const char * dart_entrypoint
Definition: flutter_windows.h:59
flutter::FlutterEngine::Run
bool Run()
Definition: flutter_engine.cc:44
flutter::FlutterEngine::ShutDown
void ShutDown()
Definition: flutter_engine.cc:65
FlutterDesktopEngineProcessMessages
uint64_t FlutterDesktopEngineProcessMessages(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:154
FlutterDesktopEngineDestroy
bool FlutterDesktopEngineDestroy(FlutterDesktopEngineRef engine_ref)
Definition: flutter_windows.cc:134
FlutterDesktopEngineCreate
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)
Definition: flutter_windows.cc:127
FlutterDesktopEngineProperties::dart_entrypoint_argc
int dart_entrypoint_argc
Definition: flutter_windows.h:62
message
Win32Message message
Definition: keyboard_unittests.cc:137
FlutterDesktopEngineSetNextFrameCallback
void FlutterDesktopEngineSetNextFrameCallback(FlutterDesktopEngineRef engine, VoidCallback callback, void *user_data)
Definition: flutter_windows.cc:183
FlutterDesktopEngineProperties::assets_path
const wchar_t * assets_path
Definition: flutter_windows.h:40
FlutterDesktopEngineRun
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)
Definition: flutter_windows.cc:144
flutter::FlutterEngine::FlutterEngine
FlutterEngine(const DartProject &project)
Definition: flutter_engine.cc:14
FlutterDesktopEngineReloadSystemFonts
void FlutterDesktopEngineReloadSystemFonts(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:158
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:46