美文网首页
Mac下Dart环境安装

Mac下Dart环境安装

作者: imkobedroid | 来源:发表于2019-06-15 03:24 被阅读0次

    安装HomeBrew

    在终端运行命令安装:

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

    安装dart

    只针对开发版进行安装

     brew tap dart-lang/dart
     brew install dart --devel
    

    这下载过程中可能会出现下面这种问题:

    Error: An exception occurred within a child process:
    DownloadError: Failed to download resource "dart"
    Download failed: https://storage.googleapis.com/dart-archive/channels/stable/release/2.0.0/sdk/dartsdk-macos-x64-release.zip

    这一般是被墙了,,但是可以通过下载地址进行手动下载,下载后将其解压出来,例如我解压出来的地址这样的:

    /usr/local/Homebrew/dart-sdk
    

    在IDEA中创建工程的时候将dart的地址指向他就行了,这样就可以使用dart了

    hello world

    运行代码:

    void main(){
      print("Hello World!");
    }
    

    结果:

    /usr/local/Homebrew/dart-sdk/bin/dart --enable-vm-service:51494 /Users/toushihiroshi/Desktop/Dart/dart/chapter1.dart
    Observatory listening on http://[::1]:51494/O-vlLQU_Dgk=/
    
    Hello World!
    
    Process finished with exit code 0
    
    

    环境变量的配置

    #Dart的配置
    export DART_HOME=/usr/local/Homebrew/dart-sdk/bin
    export PATH="${DART_HOME}:${PATH}"
    

    环境搭建完毕!

    相关文章

      网友评论

          本文标题:Mac下Dart环境安装

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