forked from firka/flutter
Update Windows app template (#65511)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user