executeSync<S> method

  1. @protected
S executeSync<S>(
  1. FlutterRustBridgeSyncTask task
)
inherited

Similar to executeNormal, except that this will return synchronously

Implementation

@protected
S executeSync<S>(FlutterRustBridgeSyncTask task) {
  final WireSyncReturn syncReturn;
  try {
    syncReturn = task.callFfi();
  } catch (err, st) {
    throw FfiException('EXECUTE_SYNC_ABORT', '$err', st);
  }
  try {
    final syncReturnAsDartObject = wireSyncReturnIntoDart(syncReturn);
    assert(syncReturnAsDartObject.length == 2);
    final rawReturn = syncReturnAsDartObject[0];
    final isSuccess = syncReturnAsDartObject[1];
    if (isSuccess) {
      return task.parseSuccessData(rawReturn);
    } else {
      throw FfiException('EXECUTE_SYNC', rawReturn as String, null);
    }
  } catch (err, st) {
    if (err is FfiException) rethrow;
    throw FfiException('EXECUTE_SYNC_ABORT', '$err', st);
  } finally {
    inner.free_WireSyncReturn(syncReturn);
  }
}