close method

Future close()

Forces the transaction to close immediately. You rarely need to call this method, since the transaction will be closed automatically by access.

After calling this method, you cannot access this transaction any more.

This method will check if rollingback is specified with a non-false value. If so, it will roll back.

Implementation

Future close() async {
  if (_closed) throw StateError('closed');

  var error;
  try {
    if (rollingback == false) {
      await _commit();
    } else {
      error = rollingback; //yes, use it as an error
      await _rollback();
    }
  } catch (ex) {
    error = ex;
    await InvokeUtil.invokeSafely(_rollback);
    rethrow;
  } finally {
    _close(error); //never throws an exception
    if (_beginCounted) --_nAccess;
  }
}