tryDraw method

CompletedFrame? tryDraw(
  1. void callback(
    1. Frame
    )?
)

Implementation

CompletedFrame? tryDraw(void Function(Frame)? callback) {
  _autoresize();
  final frame = getFrame();
  callback?.call(frame);
  _flush();
  if (frame.cursorPosition != null) {
    _backend.showCursor();
    _backend.setCursorPosition(frame.cursorPosition!);
  } else {
    _backend.hideCursor();
  }
  _swapBuffers();
  _backend.flush();
  final completed = CompletedFrame(
    buffer: _buffers[1 - _current],
    area: _lastKnownArea,
    count: _frameCount,
  );
  _frameCount++;
  return completed;
}