restoreState method

PCanvasState? restoreState({
  1. PCanvasState? expectedState,
})

Restores the drawing state.

Implementation

PCanvasState? restoreState({PCanvasState? expectedState}) {
  if (_stateStack.isEmpty) {
    throw StateError(
        "State stack error: `saveState`/`restoreState` not properly called.");
  }

  var s = _stateStack.removeLast();

  transform = s.transform;
  clip = s.clip;

  if (expectedState != null && !identical(s, expectedState)) {
    throw StateError(
        "State stack error: `expectedState` not matching the last instance in stack.");
  }

  return s;
}