ensureBoolean function

bool ensureBoolean(
  1. dynamic val
)

Implementation

bool ensureBoolean(dynamic val) {
  assertType(val, [bool, String]);
  if (val is bool) {
    return val;
  }

  if (val == "true") {
    return true;
  }
  if (val == "false") {
    return false;
  }

  throw ArgumentError("Invalid boolean string.");
}