Flutter - Trouble launching app for debug on macOS
open .vscode/launch.json
and inside "configurations" add "program"
"configurations": [ { "name": "Flutter", "request": "launch", "type": "dart", "program": "lib/your_class/file_name_with_main_function.dart" } ]
Replace 'lib' with folder and 'your_class/file_name_with_main_function' with the class name that hold main function
You could theoretically change an option in Debug > Open Configurations to make it run a different file, although I don't see the option. But even if you figure that out, it probably isn't advisable. When you do a 'build' to deploy the app, it's probably going to assume main.dart is the file to run and might fail if it can't find it.
I'd advise keeping a main.dart - it could have just the void main()
function and the rest of your code could be elsewhere, but at least then someone else coming looking at your code will be able to recognize where the main is.