Reputation: 688
I know that in Android Studio you could run a dart file that you put out of the lib folder individually much like dartpad. I'm wondering how you could do the same in VSCode. I haven't found a way to do it without it running and building the whole UI.
Upvotes: 7
Views: 6080
Reputation: 2289
dart
in Program & Working dir $ProjectFileDir$
Upvotes: 0
Reputation: 99
After creating a flutter project to run individually dart file in Flutter
you have to add main function like below code with you desire class name
void main() { runApp(newfile()); }
or
void main() => runApp(newfile());
then go to project bar of android studio right click on the selected file you will see Run'newfile.dart' then you will also see in the toolbar, select your app from the run configurations drop-down menu
like
Upvotes: 0
Reputation: 1892
You can run a dart file from the command line like this.
$ dart path_to_your_file/your_file_with_main.dart
This will execute the main() function of the file.
Upvotes: 8