toBoolean function

bool toBoolean(
  1. String str, {
  2. bool strict = false,
})

Converts the string to a boolean.

In loose mode (the default) every value is true except '', '0' and 'false'. In strict mode only '1' and 'true' are true and everything else is false. Keyword matching is case-insensitive.

Example:

toBoolean('true'); // true
toBoolean('0'); // false
toBoolean('yes', strict: true); // false

Implementation

bool toBoolean(String str, {bool strict = false}) => _toBoolean(str, strict);