Flutter 正式支援 Web 平台
Flutter 的 Web 端支援在 Web 和行動裝置上提供相同的體驗。基於 Dart 的可移植性、Web 平台的強大以及 Flutter 框架的靈活性,你現在可以從同一個程式碼庫為 iOS、Android 和瀏覽器建立應用。你可以將用 Dart 編寫的現有 Flutter 程式碼編譯成 web 體驗,因為它就是完全相同的 Flutter 框架,而 Web 只是你的應用的另一個裝置目標。
向 Flutter 新增 Web 支援涉及在標準瀏覽器 API 之上實現 Flutter 的核心繪圖層。透過結合使用 DOM、Canvas 和 CSS,Web 支援旨在為現代瀏覽器提供便攜、高質量和高效能的使用者體驗。我們在 Dart 中完全實現了這個核心繪圖層,並使用 Dart 的最佳化過的 JavaScript 編譯器將 Flutter 核心與框架,同你的應用程式一起編譯成一個可以部署到任何 Web 伺服器的簡化源檔案。
While you can do a lot on the web, Flutter’s web support is most valuable in the following scenarios:
- A Progressive Web Application built with Flutter
- Flutter delivers high-quality PWAs that are integrated with a user’s environment, including installation, offline support, and tailored UX.
- Single Page Application
- Flutter’s web support enables complex standalone web apps that are rich with graphics and interactive content to reach end users on a wide variety of devices.
- Existing mobile applications
- Web support for Flutter provides a browser-based delivery model for existing Flutter mobile apps.
Not every HTML scenario is ideally suited for Flutter at this time. For example, text-rich, flow-based, static content such as blog articles benefit from the document-centric model that the web is built around, rather than the app-centric services that a UI framework like Flutter can deliver. However, you can use Flutter to embed interactive experiences into these websites.
For a glimpse into how to migrate your mobile app to web, see the following video:
關於 web 支援的說明
以下資源可以幫助你入門:
-
要向現有應用新增Web支援,或建立一個包含 Web 支援的新應用,請參閱 使用 Flutter 建立 Web 應用。
-
瞭解更多關於 Flutter web 渲染器 (HTML and CanvasKit) 的不同之處,請查閱網頁渲染器。
-
想了解如何建立回應式 Flutter 應用,請參閱 建立回應式應用。
-
要瀏覽常見問題和答案,請參閱 Web 常見問題。
-
要檢視程式碼實例,請檢視 Web 平台範例程式碼。
-
檢視 Flutter web 應用的範例,可以試試看 Wonderous app。
-
要了解關於發布 Web 應用的訊息,請參閱 Preparing an app for web release。
-
請從 File an issue 向 Flutter 主倉庫提一個 issue。
-
你可以在 Discord 的 #help 頻道諮詢 web 相關的問題。