selectObjectDrawable method

void selectObjectDrawable(
  1. ObjectDrawable? drawable
)

Selects an object drawable from the list of drawables.

If the drawable is not in the list of drawables or is the same as selectedObjectDrawable, nothing happens and notifyListeners is not called.

Calling this will notify all the listeners of this PainterController that they need to update (it calls notifyListeners). For this reason, this method should only be called between frames, e.g. in response to user actions, not during the build, layout, or paint phases.

Implementation

void selectObjectDrawable(ObjectDrawable? drawable) {
  if (drawable == value.selectedObjectDrawable) return;
  if (drawable != null && !value.drawables.contains(drawable)) return;
  value = value.copyWith(
    selectedObjectDrawable: drawable,
  );
}