asyncDecrypt function

Future asyncDecrypt(
  1. Map<String, dynamic>? keyStore,
  2. String? psw
)

Implementation

Future<dynamic> asyncDecrypt(
  Map<String, dynamic>? keyStore,
  String? psw,
) async {
  final response = new ReceivePort();

  await Isolate.spawn(
    _isolate_decrypt,
    response.sendPort,
    onExit: response.sendPort,
    onError: response.sendPort,
  );

  final sendPort = await response.first as SendPort;
  final receivePort = new ReceivePort();

  sendPort.send([keyStore, psw, receivePort.sendPort]);

  try {
    final result = await receivePort.first;
    var resultString = result.toString();

    if (resultString.startsWith('@@LaksaError@@')) {
      throw resultString.substring(14);
    }
    response.close();
    return result;
  } catch (e) {
    rethrow;
  }
}