Flutter 3.13 修復了可能導致視窗不顯示的錯誤。使用 Flutter 3.7 或 Flutter 3.10 建立的 Windows 專案需要遷移才能修復此問題。

遷移步驟

#

使用 flutter --version 驗證您是否使用的是 Flutter 3.13 或更高版本。如有必要,請使用 flutter upgrade 更新到最新版本的 Flutter SDK。

未修改其 windows/runner/flutter_window.cpp 檔案的專案將由 flutter runflutter build windows 自動遷移。

已修改其 windows/runner/flutter_window.cpp 檔案的專案可能需要手動遷移。

遷移前的程式碼

cpp
flutter_controller_->engine()->SetNextFrameCallback([&]() {
  this->Show();
});

遷移後的程式碼

cpp
flutter_controller_->engine()->SetNextFrameCallback([&]() {
  this->Show();
});

// Flutter can complete the first frame before the "show window" callback is
// registered. The following call ensures a frame is pending to ensure the
// window is shown. It is a no-op if the first frame hasn't completed yet.
flutter_controller_->ForceRedraw();

示例

#

PR 995 展示了 Flutter Gallery 應用的遷移工作。