Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a Dart scratch file? There does not seem to be an option to run

Android Studio 3.2

File > New > Scratch File This created a new file, scratch.dart

I entered some simple Dart code.

void main() { print('This is the output'); }

How do I run this code? I've searched around the IDE and cannot find anything. What is the purpose of the scratch file if I cannot run test (Dart) code in it? Thanks.

like image 880
Lord Null Avatar asked Dec 10 '25 04:12

Lord Null


1 Answers

Scratch files aren't meant to run code instead they're used for quick drafts or writing notes/functions so you don't mess up the main code.

The only way you can run the code inside a scratch file is by using the terminal:

dart /path_to_file/scratch.dart

If you need to run a testing code inside the IDE all you gotta do is creating a regular Dart file inside Dart or Flutter project.

like image 163
Sam Avatar answered Dec 12 '25 22:12

Sam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!