checkValueType function
Implementation
Object? checkValueType(Object? value, Object? defaultValue) {
if (value.runtimeType == defaultValue.runtimeType) {
return value;
}
if (value is num && defaultValue is num) {
if (defaultValue is double) {
return value.toDouble();
} else if (defaultValue is int) {
return value.toInt();
}
}
if (defaultValue is String) {
return value.toString();
}
if (defaultValue == null) {
return value;
}
return null;
}