Flutter Setting

前言

Flutter是Google的跨平台框架,说白了就是UI跨平台。RN 凉了,Flutter 真的有春天吗?而且Google相对Facebook来说,更加靠谱一点,再不济,Android平台一定会完美支持的。自从苹果限制热修复之后,JS成了前端和移动端公认低成本,兼容最强的热更新方案,但是原生跟JS频繁的交互,整体性能令人担忧。Flutter里面同时提供了两种UI库的风格,第一种肯定是Material Design风格,还有就是Cupertino风格,也就是iOS中采用的风格。个人理解应该是Flutter封装了一套完整的UI的API,在开发时候可以直接使用,通过官网介绍了解应该也可以直接调用Android和iOS中的原生API。Flutter推出已经有段时间,网上讨论很是火热,有的说没必要入坑,有的大力推荐,还有的人在为Android开发担忧,个人感觉完全没必要担心,Flutter只能是一个趋势,不会替代,期待后续Google对Flutter的更新和优化吧。

本文详细介绍在mac下配置Flutter环境的每一个步骤,通过图文的方式使得读者快速理解和掌握Flutter的环境搭建流程。

下载flutter

推荐去官网下载,速度并不慢,网址:

https://flutter.io/setup-macos/

点击链接:


配置环境变量

先把刚才下载的flutter_***.zip解压缩到选择使用的目录文件夹

配置环境变量,命令大法:

vim ~/.bash_profile

增加一行:

exportPATH=/app/flutter/bin:$PATH

保存完毕后执行下面命令生效:

source~/.bash_profile

此时可以运行flutter命令:

flutter -h

展示flutter的命令帮助:

检查环境

运行命令行:

flutter doctor(该过程巨慢无比,耐心等待)

不出意外各种检测不通过(有[!] ✗ 标志,表示本行检测不通过)

解决检测不通过

[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)

! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licens

运行flutter doctor --android-licenses命令

国际惯例,一路Y搞定

✗ ideviceinstaller is not installed; this is used to discover connected iOS devices.

To install, run:

brew install --HEAD libimobiledevice

brew install ideviceinstaller

✗ ios-deploy not installed. To install:

brew install ios-deploy

✗ CocoaPods not installed.

CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.

Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.

For more info, seehttps://flutter.io/platform-plugins

To install:

brew install cocoapods

pod setup

运行命令:

brew install --HEAD libimobiledevice

brew install ideviceinstaller

brew install ios-deploy

brew install cocoapods

pod setup

其实根据检测不通过的错误信息就能知道我们该执行什么命令解决的,比如遇到如下检测不通过的信息:

执行命令:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

brew update

brew uninstall --ignore-dependencies libimobiledevice

brew uninstall --ignore-dependencies usbmuxd

brew install --HEAD usbmuxd

brew unlink usbmuxd

brew link usbmuxd

brew install --HEAD libimobiledevice

brew install ideviceinstaller

pod setup

就可以解决上述检测不通过的问题,每个人可以能遇到问题不同,但是解决问题的套路都是一样,都会提示你该怎么处理。

[✓] Android Studio (version 3.0)

✗ Flutter plugin not installed; this adds Flutter specific functionality.

✗ Dart plugin not installed; this adds Dart specific functionality.

打开android studio, 打开plugin

安装,重启,再次运行:

直到检测都通过为止,就可以了,不通过的地方按照指引来做就好了。

该问题我没遇到过,但是有人遇到过,python版本?之前装过python?人品?不晓得跟什么有关系,记录一下,如果按照指引来做,会一直卡在这里。这里要先重装一下python,运行下面的命令:

brew reinstall python@2

pip install six

你可能感兴趣的:(Flutter Setting)