swap method

void swap(
  1. Layer<T> layer
)

Swap the top-most Layer on the stack for the given layer.

This is equivalent to a pop followed by a push.

Implementation

void swap(Layer<T> layer) {
  if (_layers.isNotEmpty) {
    var top = _layers.removeLast();
    top._unbindUi();
  }

  layer._bindUi(this);
  _layers.add(layer);
  dirty();
}