Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • DART Cookbook
  • Toc
  • feedback
DART Cookbook

DART Cookbook

By : Ivo Balbaert
4 (2)
close
DART Cookbook

DART Cookbook

4 (2)
By: Ivo Balbaert

Overview of this book

If you are a Dart developer looking to sharpen your skills, and get insight and tips on how to put that knowledge into practice, then this book is for you. You should also have a basic knowledge of HTML, and how web applications with browser clients and servers work, in order to build dynamic Dart applications.
Table of Contents (13 chapters)
close
12
Index

Exiting from an app


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 itself? This can be useful, for example, in a server-side VM app with some Futures that may or may not return.

How to do it...

The first possibility is to use the exit(int code) top-level function from dart:io, as in exit_app.dart, to stop the app...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete