asBool property

bool asBool

Convert this string into boolean.

Returns true if this string is any of these values: "true", "yes", "1", or if the string is a number and greater than 0, false if less than 1. This is also case insensitive.

Implementation

bool get asBool {
  String s = trim().toLowerCase();
  num n;
  try {
    n = num.parse(s);
  } on Exception catch (e, s) {
    n = -1;
    errorLogsNS("Error in toList\n\n *$this* ", e, s);
  }
  return s == 'true' || s == 'yes' || n > 0;
}