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.
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.
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