I wanted to create a Dart project to play around with, but I couldn't figure out how to create one from the command line.
I tried
dart create playground.dart
I also tried
dart playground.dart
but the code I pasted in had dependency requirements.
Run the app To run the app from the command line, use the Dart VM by running the dart run command in the app's top directory: $ cd cli $ dart run Hello world: 42!
Go to android studio settings by following this flow. File => Settings => Languages & Frameworks and select Dart check its Sdk path is it correct or not and is the dart support is enabled for your project or not.
The dart tool ( bin/dart ) is a command-line interface to the Dart SDK. The tool is available no matter how you get the Dart SDK—whether you download the Dart SDK explicitly or download only the Flutter SDK.
The easiest way to create a new project is to use Stagehand. This is the same that IntelliJ uses when creating a new Dart project.
You can install it with this command
pub global activate stagehand
And then all you have to do to use it is
mkdir playground
cd playground
stagehand <generator-name>
These are the different generator you can use right now:
Dart now supports creating projects directly. No more need for stagehand.
dart create playground
This creates a folder named playground
with a Dart project inside.
mkdir playground
playground.dart
void main() {
print("hello world");
}
dart playground.dart
Create a pubspec.yaml file
touch pubspec.yaml
Paste in any dependencies that you have
name: playground
description: Just a place to practice
version: 0.0.1
dependencies:
crypto: ^2.0.6
pub get
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With