編寫一個App就能編譯發佈到iOS、Android和Web等各大平臺的跨平臺技術,各大廠商一直都有研究和發佈對應技術產品,目前最熱門的莫過於Flutter框架了。而Dart作為其唯一的編程語言,今天我們開始來體驗一下…… ...
本博客原地址:https://ntopic.cn/p/2023092301/
Dart的安裝方式有幾種:一種是下載源代碼,然後編譯安裝;一種是通過包管理工具進行安裝。
Dart官方網站分表列出了針對Windows、Linux和MacOS的安裝方式:https://dart.dev/get-dart
我下麵在個人MacOS上介紹brew
包管理工具安裝方法和過程:
安裝HomeBrew包管理工具:brew
HomeBrew是MacOS的一個包管理工具,有了它,後面安裝、更新、配置等操作就容易多了:https://brew.sh
獲取Dart:brew tap dart-lang/dart
本命令作用是獲取Dart的安裝包列表。由於需要從GitHub拉取包數據,訪問GitHub不穩定容易失敗,重試幾次即可:
SZH-MacBook:~ shizihu$ brew tap dart-lang/dart
Running `brew update --auto-update`...
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:61029cec31c68a1fae1fa90fa876adf43d0becff777da793f9b5c5577f00567a
################################################################################### 100.0%
==> Pouring portable-ruby-2.6.10_1.el_capitan.bottle.tar.gz
==> Homebrew collects anonymous analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this `brew` run).
Installing from the API is now the default behaviour!
You can save space and time by running:
brew untap homebrew/core
==> Downloading https://formulae.brew.sh/api/formula.jws.json
################################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
################################################################################### 100.0%
==> Tapping dart-lang/dart
Cloning into '/usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart'...
remote: Enumerating objects: 3737, done.
remote: Counting objects: 100% (1491/1491), done.
remote: Compressing objects: 100% (387/387), done.
remote: Total 3737 (delta 1242), reused 1301 (delta 1098), pack-reused 2246
Receiving objects: 100% (3737/3737), 674.85 KiB | 127.00 KiB/s, done.
Resolving deltas: 100% (2518/2518), done.
Tapped 22 formulae (53 files, 862.2KB).
安裝Dart:brew install dart
從安裝日誌可以看出:
- Dart安裝版本:3.1.2
- Dart安裝路徑:/usr/local/Cellar/dart/3.1.2
- Dart命令路徑:/usr/local/opt/dart/libexec
SZH-MacBook:~ shizihu$ brew install dart
==> Fetching dart-lang/dart/dart
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/release/3.1.2/
################################################################################### 100.0%
==> Installing dart from dart-lang/dart
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences.
If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Alternatively, manually download them from:
https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 14.2.
==> Caveats
Please note the path to the Dart SDK:
/usr/local/opt/dart/libexec
==> Summary