Update Windows app template (#65511)

This commit is contained in:
stuartmorgan
2020-09-10 16:10:04 -04:00
committed by GitHub
parent 0ea0e9d0b3
commit ee4fa1b34e
4 changed files with 16 additions and 16 deletions

View File

@@ -17,22 +17,23 @@ bool FlutterWindow::OnCreate() {
RECT frame = GetClientArea();
// The size here must match the window dimensions to avoid unnecessary surface creation / destruction in the startup path.
flutter_controller_ =
std::make_unique<flutter::FlutterViewController>(frame.right - frame.left, frame.bottom - frame.top, project_);
// The size here must match the window dimensions to avoid unnecessary surface
// creation / destruction in the startup path.
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
frame.right - frame.left, frame.bottom - frame.top, project_);
// Ensure that basic setup of the controller was successful.
if (!flutter_controller_->engine() || !flutter_controller_->view()) {
return false;
}
RegisterPlugins(flutter_controller_.get());
run_loop_->RegisterFlutterInstance(flutter_controller_.get());
RegisterPlugins(flutter_controller_->engine());
run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());
return true;
}
void FlutterWindow::OnDestroy() {
if (flutter_controller_) {
run_loop_->UnregisterFlutterInstance(flutter_controller_.get());
run_loop_->UnregisterFlutterInstance(flutter_controller_->engine());
flutter_controller_ = nullptr;
}