clone method

Future<T> clone()

Implementation

Future<T> clone() async {
  final receive = ReceivePort();

  try {
    receive.sendPort.send(this);

    final cloned = await receive.first;

    return cloned as T;
  } catch (e) {
    throw CloneException('Failed to clone object: $e');
  } finally {
    receive.close();
  }
}