Dart programming language | Credited: Dart | Source


How to Run a Dart Script

A no-frills tutorial on how to set up and run a Dart script.

1 Introduction

I have been working with Dart for a while now because it is the native language of Flutter. I was wondering how I could use it for scripting and it is actually really simple!

2 Methods

All you have to do is:

  1. Create a foo.dart file.
  2. Write a main function which allows execution of the .dart file as a program or script.
  3. Write your desired code within the main function.

For example,

3 Conclusion

Let me know if it didn't work for you. Have fun!