didRequestAppExit method

Future<AppExitResponse> didRequestAppExit()

Called when a request is received from the system to exit the application.

If any observer responds with AppExitResponse.cancel, it will cancel the exit. All observers will be asked before exiting.

Not all exits are cancelable, so not all exits will call this function. Do not rely on this function as a place to save critical data, because you will be disappointed. There are a number of ways that the application can exit without letting the application know first: power can be unplugged, the battery removed, the application can be killed in a task manager or command line, or the device could have a rapid unplanned disassembly (i.e. it could explode). In all of those cases (and probably others), no notification will be given to the application that it is about to exit.

See also:

Implementation

Future<AppExitResponse> didRequestAppExit() async {
  return AppExitResponse.exit;
}