boolify static method

bool boolify(
  1. dynamic value
)

Returns the truthy value of value, or throws an exception.

  • If value is null - returns false.
  • If value is a bool - returns value.
  • If value is a String - returns false for "", "0", and the word "false" (case-insensitive), and true otherwise.
  • If value is a num - returns false for zero, and true otherwise.
  • Otherwise - throws an exception

Implementation

static bool boolify(dynamic value) {
	bool? b = EZ.tryBoolify(value);
	if (b == null) {
		throw "don't know how to boolify [${value}]";
	}
	return b;
}