removeObject method
Calling this will notify all the listeners of this WindowPaintController that they need to update (it calls notifyListeners()). For this reason, this value should only be set between frames, e.g. in response to user actions, not during the build, layout, or paint phases.
This method can be called from a listener added to this WindowPaintController; however, one should not call it repeatedly. To remove multiple DrawObject call removeObjectsWhere().
Calling this will cancel the current selection if object
is
the currently selected object.
Implementation
void removeObject(DrawObject object) {
final idx = objects.indexOf(object);
if (idx != -1) {
objects.removeAt(idx);
// This will call notifyListeners() for us
value = value.copyWith(
selectedObjectIndex: _computeNewSelectedObjectIndex(idx),
);
}
}