今天介紹一個能讓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,可以在全平台運行了。
那具體要怎麼操作呢?
這裡我們用MusesWeather項目做實驗。
項目地址:https://github.com/KinsomyJS/muses_weather_flutter
文章地址:https://juejin.im/post/5bc43027f265da0ad221b5e5
按照提示需要增加兩處代碼,在項目的main.dart文件添加import package:flutter/foundation.dart;, 在main方法里添加debugDefaultTargetPlatformOverride = TargetPlatform.iOS;。
import package:flutter/foundation.dart;
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
這樣就得到了一個添加好了的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商店並且更新。
TAG:macOS | Flutter |