toBool property

bool get toBool

Attempts to convert the string to a boolean value. Supports "true" and "false", case-insensitive.

Example:

print('true'.toBool); // Output: true
print('False'.toBool); // Output: false
print('abc'.toBool); // Output: false

Implementation

bool get toBool => bool.tryParse(this) ?? false;