cancelOptimize method

Future<void> cancelOptimize()

Requests cancellation of the optimization run currently in flight.

Cancellation is cooperative: the native run stops at the next page boundary and the pending optimizeToFile future resolves with CPDFOptimizeResult.cancelled set to true. Calling it while no run is in flight does nothing.

Since v3.2.0

example:

await document.cancelOptimize();

Implementation

Future<void> cancelOptimize() async {
  try {
    await _channel.invokeMethod('cancel_optimize');
  } on PlatformException catch (e) {
    throw CPDFOptimizeException(e.code, e.message ?? '');
  }
}