shutdown method

  1. @override
Future<MoveShutdownResult> shutdown({
  1. bool force = true,
  2. int? timeoutSeconds,
})
override

Shutdown SDK shared instance.

Stops SDK services, sends the queued user data, and de-intialized the SDK. After that is executed, the SDK State.uninitialized is triggered. The force parameter (default: true) will discard pending data to be uploaded. With force = true shudown will always succseed. The timeoutSeconds parameter (in seconds) bounds how long the SDK tries to send pending data before shutting down. Use with force = false.

Implementation

@override
Future<MoveShutdownResult> shutdown(
    {bool force = true, int? timeoutSeconds}) async {
  try {
    await methodChannel.invokeMethod('shutdown', <String, dynamic>{
      'force': force,
      'timeoutSeconds': timeoutSeconds,
    });
  } on PlatformException catch (e) {
    if (e.message?.contains('connection pool has been closed') ?? false) {
      print('DB closed - ignoring');
      return MoveShutdownResult.success;
    }
    switch (e.code) {
      case "uninitialized":
        return MoveShutdownResult.uninitialized;
      case "networkError":
        return MoveShutdownResult.networkError;
    }
  }

  return MoveShutdownResult.success;
}