when method
Implementation
Object when({
int Function(int)? isInt,
double Function(double)? isDouble,
bool Function(bool)? isBool,
String Function(String)? isString,
List Function(JSArray)? isArray,
Map Function(JSAny)? isMap,
Object Function(Object)? isOther,
}) {
if (isArray != null && isJavaScriptArray(this)) {
return isArray(this as JSArray);
}
if (isInt != null && (this is num || instanceOfString(this, 'Number'))) {
return isInt(this as int);
}
if (isDouble != null && (this is num || instanceOfString(this, 'Number'))) {
return isDouble(this as double);
}
if (isBool != null && (this is bool || instanceOfString(this, 'Boolean'))) {
return isBool(this as bool);
}
if (isString != null &&
(this is String || instanceOfString(this, 'String'))) {
return isString(this as String);
}
if (isMap != null && isJavaScriptSimpleObject(this)) {
return isMap(this as JSAny);
}
if (isOther != null) {
return isOther(this);
}
throw Exception('Unknown javascript object $this $runtimeType');
}