介紹

今天介紹一個能讓Flutter應用執行在Mac OS和Windows上的平臺:Feather Platform
官網地址:feather-apps.com/
官網的介紹如下:
The Feather platform will run Flutter apps on MacOS and Windows. So you can write a single app that runs on all major desktop and mobile devices.
基本可以說寫一次flutter app,可以在全平臺執行了。
那具體要怎麼操作呢?
實踐
1.在官網首頁點選按鈕 Build an App Now,會下載程式安裝包。

2.下載之後開啟安裝應用,就進入瞭如下的應用介面。

3.用谷歌賬號登入(需要科學上網)。

4.點選右下角“新增”按鈕。

5.點選"BROWSE"選擇一個已經開發完成的Flutter專案。
這裡我們用MusesWeather專案做實驗。
6.增加程式碼

按照提示需要增加兩處程式碼,在專案的main.dart檔案新增import 'package:flutter/foundation.dart';
,
在main方法裡新增debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
。
7.新增App Name並點選Continue

這樣就得到了一個新增好了的App專案,點選進去會看到

點選TEST就會提示你開啟Xcode,然後在Xcode裡面run 工程。

產品
最後我們就成功將寫好的Flutter 專案執行在了Mac OS上,感興趣的同學可以立馬嘗試下。

解釋
How is this different to the flutter-desktop-embedding project?
Feather is actually based on the flutter-desktop-embedding project. Currently for Mac it offers the same features plus:
(a) More functionality like copy and paste, mouse wheel and escape key
(b) More supported plugins like shared_preferences, url_launcher, google_sign_in
(c) An easy way to publish your app and push updates to end users
其實Feather Platform就是在Google開源專案flutter-desktop-embedding的基礎上開發的,並提供了更多的特性:
- 鍵盤和滑鼠等輸入裝置
- 支援更多外掛如持久化,google登入等
- 可以釋出app到Feather商店並且更新。