toggle method

bool toggle()

Toggles the boolean value.

Returns the opposite of the current value.

Example:

bool flag = true;
flag = flag.toggle(); // false
flag = flag.toggle(); // true

Implementation

bool toggle() => !this;