whenTrue method

void whenTrue(
  1. void action()
)

Executes the action only if the boolean is true.

Example:

bool flag = true;
flag.whenTrue(() => print("Flag is true"));

Implementation

// Output: Flag is true
/// ```
void whenTrue(void Function() action) {
  if (this) action();
}