我想创建一个Dart项目来玩,但我无法弄清楚如何从命令行创建一个。
我试过了
dart create playground.dart
我也试过了
dart playground.dart
但我粘贴的代码有依赖性要求。
创建新项目的最简单方法是使用Stagehand。这与IntelliJ在创建新Dart项目时使用的相同。
您可以使用此命令安装它
pub global activate stagehand
然后你需要做的就是使用它
mkdir playground
cd playground
stagehand <generator-name>
这些是您现在可以使用的不同生成器:
mkdir playground
playground.dart
void main() {
print("hello world");
}
dart playground.dart
创建pubspec.yaml文件
touch pubspec.yaml
粘贴您拥有的任何依赖项
name: playground
description: Just a place to practice
version: 0.0.1
author: suragch
dependencies:
crypto: ^2.0.6
pub get