美文网首页
macOS上搭建Flutter开发环境

macOS上搭建Flutter开发环境

作者: testerzhang | 来源:发表于2020-06-16 16:10 被阅读0次

    前言

    看到Flutter,今天搭建记录一下。

    使用镜像

    由于在国内访问Flutter有时可能会受到限制,Flutter官方为中国开发者搭建了临时镜像,大家可以将如下环境变量加入到用户环境变量中:

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

    注意: 此镜像为临时镜像,并不能保证一直可用,读者可以参考详情请参考 Using Flutter in China 以获得有关镜像服务器的最新动态。

    下载Flutter SDK

    # wget https://storage.googleapis.com/flutter_infra/releases/stable/macos/flutter_macos_1.17.3-stable.zip
    
    # unzip flutter_macos_1.17.3-stable.zip
    

    设置环境变量

    export PATH=/work/tools/flutter/flutter/bin:$PATH
    
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    

    下载Android Studio

    https://developer.android.com/studio 进行下载,下载后会要求下载Android SDK,按照提示下载即可。

    Flutter 检查

    # flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.12.6 16G29, locale zh-Hans-CN)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    [✗] Xcode - develop for iOS and macOS
        ✗ 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
            sudo xcodebuild -runFirstLaunch
        ✗ CocoaPods not installed.
            CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart
            side.
            Without CocoaPods, plugins will not work on iOS or macOS.
            For more info, see https://flutter.dev/platform-plugins
          To install:
            sudo gem install cocoapods
    [✓] Android Studio (version 4.0)
    [✓] Connected device (1 available)
    
    ! Doctor found issues in 1 category.
    

    因为我有安卓手机,就不搞ios了。

    相关文章

      网友评论

          本文标题:macOS上搭建Flutter开发环境

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