toggleAttribute function

bool toggleAttribute(
  1. bool val
)

Toggles attribute

Example:

@Component(/*...*/)
class SomeComponent{
  @Input('[attr.someInput]')
  var someInput;
  bool get isSomeInput => isPresent(someInput);

  void toggle() {
    toggleAttribute(someInput);
  }
}

Implementation

bool toggleAttribute(bool val) {
  // In Angular, an attribute is removed if it's value is `null` and added
  // if it's anything else, like
  return !isPresent(val) ? true : null;
}