close method Null safety

  1. @override
void close()
override

Closes the sink.

The add method must not be called after this method.

Calling this method more than once is allowed, but does nothing.

Implementation

@override
void close() {
  assert(!_closed);
  final bs = _cipher.blockSize;
  if (_lastPlaintextPos > 0) {
    for (var i = _lastPlaintextPos; i < bs; i++) {
      _lastPlaintext[i] = 0;
    }
  }
  _padding.addPadding(_lastPlaintext, _lastPlaintextPos);
  _emit(_lastPlaintext, 0, _lastPlaintext.length);
  _closed = true;
  _dest.close();
}