dart: Dart 命令列工具
dart 工具 (bin/dart) 是 Dart SDK 的命令列介面。無論您如何獲取 Dart SDK(是明確下載 Dart SDK 還是僅下載 Flutter SDK),此工具都可用。
以下是您可以使用 dart 工具建立、分析、測試和執行應用程式的方式
dart create -t console my_app
cd my_app
dart analyze
dart test
dart run bin/my_app.dart您還可以使用 dart 工具執行 pub 命令。
dart pub get
dart pub outdated
dart pub upgrade下表顯示了可以與 dart 工具一起使用的命令。如果您正在進行 Flutter 開發,則可能會改用 flutter 工具。
|
| 命令 | 使用示例 | 更多資訊 |
|---|---|---|
analyze | dart analyze [<目錄|Dart_檔案>] | 分析專案的 Dart 原始碼。 瞭解更多。 |
compile | dart compile exe <Dart_檔案> | 將 Dart 編譯為各種格式。 替換了 dart2js 和 dart2native。瞭解更多。 |
create | dart create <目錄> | 建立一個新專案。 瞭解更多。 |
doc | dart doc <目錄> | 生成 API 參考文件。 替換了 dartdoc。瞭解更多。 |
fix | dart fix <目錄|Dart_檔案> | 對 Dart 原始碼應用自動化修復。 瞭解更多。 |
format | dart format <目錄|Dart_檔案> | 格式化 Dart 原始碼。 瞭解更多。 |
info | dart info | 輸出 Dart 工具診斷資訊。 瞭解更多。 |
pub | dart pub <PUB_命令> | 處理包。 替換了 pub。瞭解更多。 |
run | dart run <Dart_檔案> | 執行 Dart 程式。 替換了現有的 Dart VM 命令 (不帶命令的 dart)。瞭解更多。 |
test | dart test <目錄|Dart_檔案> | 在此包中執行測試。 替換了 pub run test。瞭解更多。 |
| (無) | dart <Dart_檔案> | 執行 Dart 程式;與現有的 Dart VM 命令相同。 優先使用 dart run。 |
要獲取任何命令的幫助,請輸入 dart help <命令>。您還可以獲取 pub 命令的詳細資訊。
dart help pub outdated