Flutter 安装

版权声明:本文为博主原创文章,未经博主允许不得转载、不得商业用途。 https://blog.csdn.net/chenlove1/article/details/82778140

    简单地说:Flutter 是一个移动 SDK ,可以创建混合移动应用(编写一份代码,在 Android 和 iOS 都可以运行这个应用程序)。

学习地址 Flutter中文网:https://flutterchina.club/

本人开始入坑flutter,使用mac系统进行安装,遇到了一些坑,记录一下,并简单总结一下步骤。

1.首先为什么要用 Flutter ?

1.1 应用运行期间使用热重载改变 UI

1.2 非常丰富的内置 UI 组件

1.3  UI 非常简单—— 所有东西都是一个小部件

1.4 兼容Android / iOS 差异化主题

1.5 谷歌亲儿子-社区活跃(http://flutter-dev.cn/)、资源丰富(https://pub.dartlang.org/flutter

2.安装Flutter SDK

2.1下载地址:https://flutter.io/sdk-archive/#macos

(ps:昨天下载的v0.8.6,今天就更新到0.9.1)

2.2 解压到你电脑某个文件夹下 ,如:

cd ~/development
unzip ~/Downloads/flutter_macos_v0.8.6-dev.zip 

解压完成

3.配置环境变量

export PUB_HOSTED_URL=https://pub.flutter-io.cn

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

export PATH=`pwd`/flutter/bin:$PATH

export PATH=/Users/yingyou/Documents/flutter/bin:$PATH

export ANDROID_HOME=/Users/yingyou/Documents/android/sdk

export PATH=${PATH}:${ANDROID_HOME}/tools

export PATH=${PATH}:${ANDROID_HOME}/platform-tools

export PUB_HOSTED_URL=https://pub.flutter-io.cn

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

终端配置方法:

env //查看环境变量

cd ~ && ls -a && sudo vim .bashrc  //修改环境变量,输入上面的环境变量

//输完后依次按 'esc'  => ':wq'

source ~/.bashrc   //配置生效 //在终端再输入env查看是否成功

flutter doctor  //命令查看是否需要安装其它依赖项来完成安装

坑:-bash: flutter: command not found

1.检查ANDROID_HOME的值路径是不是指向你的android sdk的路径(我已经安装好Android Studio),上面是写错了Documents,要改为Library

2.检查PATH=/Users/yingyou/Documents/flutter/bin:$PATH是否指向你解压flutter sdk的路径

3.再次执行 sourece ~/.basehrc 然后 flutter !

4.苹果应用商店安装xcode

5.在Anroid Studio 安装插件

Flutter、Dart(打开插件首选项 Preferences>Plugins )

6.安装brew及CocoaPods

安装brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

安装CocoaPods: sudo gem install cocoapods

7.其他问题

flutter docto 提示以下信息:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.8.6, on Mac OS X 10.13.6 17G65, locale zh-Hans-CN)
[✗] Android toolchain - develop for Android devices
    ✗ ANDROID_HOME = /Users/yingyou/Documents/android/sdk
      but Android SDK not found at this location.
[✗] iOS toolchain - develop for iOS devices
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
    ✗ Brew not installed; use this to install tools for iOS device development.
      Download brew at https://brew.sh/.
[✓] Android Studio (version 3.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] Connected devices
    ! No devices available

再终端一个个执行下面(执行后,flutter doctor还会提示,重启一下电脑即可):

brew install --HEAD libimobiledevice

brew install ideviceinstaller

brew install ios-deploy

brew install cocoapods

pod setup

完毕!

 

猜你喜欢

转载自blog.csdn.net/chenlove1/article/details/82778140