getRenderObject method

RenderObject? getRenderObject()

Returns render object representation of this snapshot. Note that this can only be called per snapshot. After that the render object is free to be disposed. If you need to use snapshot in multiple places (i.e. lift & drag having same image) use retain to increase the retain count.

Implementation

RenderObject? getRenderObject() {
  assert(!_disposed);
  assert(_retainCount > 0);
  --_retainCount;

  if (_retainCount == 0) {
    _onRenderObjectRequested.notify();
  }
  if (_retainCount >= 0) {
    return _renderObject!;
  } else {
    return null;
  }
}