removeIfExists method

If removeIfExists({
  1. Widget? then,
})

The removeIfExists method removes the tag and may execute some action before if the tag exists.

Tag('mytag',entity:Entity.Selected()).removeIfExists(
	then: Say(msg:'removed')
) // optional argument
⇒ execute if entity @s[tag=mytag] run say removed
⇒ execute if entity @s[tag=mytag] run tag @s remove mytag

Implementation

If removeIfExists({Widget? then}) {
  return If(this, then: [if (then != null) then, remove()]);
}