快讓Flutter應用跑Mac上
介紹

今天介紹一個能讓Flutter應用運行在Mac OS和Windows上的平台:Feather Platform
官網地址:https://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項目做實驗。
項目地址:https://github.com/KinsomyJS/muses_weather_flutter
文章地址:https://juejin.im/post/5bc43027f265da0ad221b5e5
6.增加代碼

按照提示需要增加兩處代碼,在項目的main.dart文件添加import package:flutter/foundation.dart;
, 在main方法里添加debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
。
7.添加App Name並點擊Continue

這樣就得到了一個添加好了的App項目,點擊進去會看到

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

產品
最後我們就成功將寫好的Flutter 項目運行在了Mac OS上,感興趣的同學可以立馬嘗試下。
項目地址:https://github.com/KinsomyJS/muses_weather_flutter
解釋
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商店並且更新。
推薦閱讀: