setSketch method

void setSketch({
  1. required Sketch sketch,
  2. bool addToUndoHistory = true,
})

Can be used to update the state of the Sketch externally (e.g. when fetching from a server) to what is passed in as sketch;

By default, this state of the sketch gets added to the undo history. If this is not desired, set addToUndoHistory to false.

The sketch will be simplified using the currently set simplification tolerance. If you don't want simplification, call setSimplificationTolerance to set it to 0.

Implementation

void setSketch({
  required Sketch sketch,
  bool addToUndoHistory = true,
}) {
  final newState = value.copyWith(
    sketch: sketch,
  );
  if (addToUndoHistory) {
    value = newState;
  } else {
    temporaryValue = newState;
  }
}