美文网首页
Mac系统flutter环境搭建

Mac系统flutter环境搭建

作者: 路有点颠簸 | 来源:发表于2020-05-07 10:03 被阅读0次

Flutter中文官网

flutter 用这个

1、homebrew安装

-安装 homebrew,已安装跳过
-打开终端分别输入以下命令行

brew update
brew install --HEAD libimobiledevice
brew install ideviceinstaller ios-deploy cocoapods
pod setup

2、下载flutter SDK

可直接clone,也可去官网下载后放入根目录,但是我去下载了解压后放入根目录不行,所以还是说直接clone的方式吧,打开命令行

cd ~
git clone -b stable https://github.com/flutter/flutter.git

这个只能取决于网速了,下载完成后

3、配置环境镜像

这一步必须查看文章顶部的flutter文档,文档明确指出:此镜像为临时镜像,并不能保证一直可用,读者可以参考详情请参考 Using Flutter in China 以获得有关镜像服务器的最新动态。
-跳转根目录

cd ~

-打开隐藏文件.bash_profile

vim ~/.bash_profile

-将文档中最新的镜像和路径加进去,路径自行修改,我目前的操作是放在根目录的,/Users/luohao是我的根目录

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Users/luohao/flutter/bin:$PATH  
source ~/.bash_profile

-验证环境是否成功

flutter -h

无报错则成功,成功的最后大概是这样的

Run "flutter help <command>" for more information about a command.
Run "flutter help -v" for verbose help output, including less commonly used options.

  ╔════════════════════════════════════════════════════════════════════════════╗
  ║                 Welcome to Flutter! - https://flutter.dev                  ║
  ║                                                                            ║
  ║ The Flutter tool uses Google Analytics to anonymously report feature usage ║
  ║ statistics and basic crash reports. This data is used to help improve      ║
  ║ Flutter tools over time.                                                   ║
  ║                                                                            ║
  ║ Flutter tool analytics are not sent on the very first run. To disable      ║
  ║ reporting, type 'flutter config --no-analytics'. To display the current    ║
  ║ setting, type 'flutter config'. If you opt out of analytics, an opt-out    ║
  ║ event will be sent, and then no further information will be sent by the    ║
  ║ Flutter tool.                                                              ║
  ║                                                                            ║
  ║ By downloading the Flutter SDK, you agree to the Google Terms of Service.  ║
  ║ Note: The Google Privacy Policy describes how data is handled in this      ║
  ║ service.                                                                   ║
  ║                                                                            ║
  ║ Moreover, Flutter includes the Dart SDK, which may send usage metrics and  ║
  ║ crash reports to Google.                                                   ║
  ║                                                                            ║
  ║ Read about data we send with crash reports:                                ║
  ║ https://flutter.dev/docs/reference/crash-reporting                         ║
  ║                                                                            ║
  ║ See Google's privacy policy:                                               ║
  ║ https://policies.google.com/privacy                                        ║
  ╚════════════════════════════════════════════════════════════════════════════╝

4、配置android studio完全可按照文档提示操作

5、检查flutter环境

flutter doctor

将有叉的地方全部处理掉,命令行会给出相应提示

5、处理完后再次检查,成功后是这样的

luohaos-MacBook-Pro:~ luohao$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.0, on Mac OS X 10.15.4 19E287, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Android Studio (version 3.6)
[✓] Connected device (1 available)

• No issues found!

相关文章

网友评论

      本文标题:Mac系统flutter环境搭建

      本文链接:https://www.haomeiwen.com/subject/fzloghtx.html