layer property Null safety

T? layer

The Layer whose resources this object keeps alive.

Setting a new value or null will dispose the previously held layer if there are no other open handles to that layer.

Implementation

T? get layer => _layer;
void layer=(T? layer)

Implementation

set layer(T? layer) {
  assert(
    layer?.debugDisposed != true,
    'Attempted to create a handle to an already disposed layer: $layer.',
  );
  if (identical(layer, _layer)) {
    return;
  }
  _layer?._unref();
  _layer = layer;
  if (_layer != null) {
    _layer!._refCount += 1;
  }
}