美文网首页
Flutter Mac环境搭建

Flutter Mac环境搭建

作者: 小豪丶ace | 来源:发表于2019-01-15 10:33 被阅读33次

    1. 获取Flutter SDK

    https://flutter.io/docs/development/tools/sdk/archive?tab=macos#macos
    

    解压安装包到想要的安装的目录

    2. 配置环境变量

    1.终端输入
    open .bash_profile
    
    2.在弹出的文本框输入
    #for flutter
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    export PATH=$PATH:/Users/project/flutter/bin
    
    这里/Users/project/flutter/bin是我的目录,需要替换成自己的目录
    
    3.保存配置
    source .bash_profile
    

    3. 测试环境

    终端输入
    flutter -h
    

    如果看见关于Flutter的一些帮助信息,那么环境就配置好了

    4. flutter doctor

    运行以下命令查看是否需要安装其它依赖项来完成安装

    终端输入flutter doctor
    
    结果:
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale
        zh-Hans-CN)
    [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    [✗] 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
        ✗ libimobiledevice and ideviceinstaller are not installed. To install with
          Brew, run:
            brew update
            brew install --HEAD usbmuxd
            brew link usbmuxd
            brew install --HEAD libimobiledevice
            brew install ideviceinstaller
        ✗ ios-deploy not installed. To install with Brew:
            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, see https://flutter.io/platform-plugins
          To install:
            brew install cocoapods
            pod setup
    [✓] Android Studio (version 3.1)
    [!] IntelliJ IDEA Ultimate Edition (version 2017.3.3)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
    [!] Connected device
        ! No devices available
    
    ! Doctor found issues in 3 categories.
    

    注意不用每一个[x]和[i]都需要修复
    如果只是用Flutter开发Android,那么出现上面输出信息就可以了

    开发ios需要按照提示补全配置

    [✗] iOS toolchain - develop for iOS devices
    

    5.Android环境配置

    • 安装Android Studio ,配置Android Studio开发环境
    • 打开Android Studio,在插件中搜索Flutter插件,安装重启Android Studio

    完成以上5步,就可以开始开发Android平台的Flutter应用了

    相关文章

      网友评论

          本文标题:Flutter Mac环境搭建

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