快让Flutter应用跑PC上

12,304 阅读2分钟

介绍

今天介绍一个能让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项目做实验。

项目地址:github.com/KinsomyJS/m…

文章地址:juejin.cn/post/684490…

6.增加代码

按照提示需要增加两处代码,在项目的main.dart文件添加import 'package:flutter/foundation.dart';, 在main方法里添加debugDefaultTargetPlatformOverride = TargetPlatform.iOS;

7.添加App Name并点击Continue

这样就得到了一个添加好了的App项目,点击进去会看到

点击TEST就会提示你打开Xcode,然后在Xcode里面run 工程。

产品

最后我们就成功将写好的Flutter 项目运行在了Mac OS上,感兴趣的同学可以立马尝试下。

项目地址:github.com/KinsomyJS/m…

解释

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商店并且更新。