replaceDrawable method
Replace oldDrawable
with newDrawable
in the controller value.
Returns true
if oldDrawable
was found and replaced, false
otherwise.
If the return value is false
, the controller value is unaffected.
If newAction
is true
, the action is added as an independent action
and can be undone in the future. If it is false
, the action is connected to the
previous action and is merged with it.
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.
notifyListeners will not be called if the return value is false
.
Implementation
bool replaceDrawable(Drawable oldDrawable, Drawable newDrawable,
{bool newAction = true}) {
final action = ReplaceDrawableAction(oldDrawable, newDrawable);
final value = action.perform(this);
if (value) _addAction(action, newAction);
return value;
}