Is it possible to run this code in Android studio without firing up any device, I just want to print it to the console.
void main() {
print("Hello World");
}
Note:
I am not looking for DartPad
or any other online IDE to run Dart code.
Is it possible to run this code in Android studio without firing up any device, I just want to print it to the console.
void main() {
print("Hello World");
}
Note:
I am not looking for DartPad
or any other online IDE to run Dart code.
in your Dart file right click on the green arrows in front of your main()
function:
then click on the dart icon from the popup menuCreate ...
and then OK
:
now you can run it without the simulator:
And get the console output in the Run window:
On a Unix-like system (e.g. Linux, macOS), if dart
is in your executable PATH
, you can add a shebang line to your .dart
file:
#!/usr/bin/env dart
void main() {
print("Hello World");
}
and mark your file executable (chmod a+x your_file.dart
). Then you can run your_file.dart
directly without needing to run dart your_file.dart
explicitly.
(If the dart
binary is not in PATH
, then you would need to use #!/full/path/to/dart
as the first line instead.)
On Windows, you could set up a file association for .dart
files.