toInt method

int toInt()

Converts the boolean to an integer: 1 if true, 0 if false.

Example:

bool flag = true;
print(flag.toInt()); // Output: 1

Implementation

int toInt() => this ? 1 : 0;