cast method

  1. @override
bool cast(
  1. dynamic value
)
override

Casts the argument to this data type, otherwise throw an ArgumentError.

Implementation

@override
bool cast(dynamic value) {
  if (value is bool) {
    return value;
  } else if (value is num) {
    return value != 0 && !value.isNaN;
  } else if (value is String) {
    if (_trueStrings.contains(value)) {
      return true;
    }
    if (_falseStrings.contains(value)) {
      return false;
    }
  }
  return super.cast(value);
}