A Dart program starts its execution from the
main() function in one thread (or isolate) in the Dart VM. The Dart VM by design always starts up single threaded. The program can end in three different ways:
- It can end in a normal way by executing the last statement from
main() and returning the exit code with the value 0, which means success
- It can terminate abnormally with a runtime exception, returning exit code different from 0, such as 255 in the case of an unhandled exception
- It can wait in an event loop for user interaction (such as in the browser or a web server waiting for requests), and then terminate when the browser is closed or another app is started in the same browser tab
However, how can we exit the app from the code ...