readValue static method
读取target
的原生数据值
Implementation
static dynamic readValue(dynamic target, {String? type}) {
final value = target is VmObject ? target.getValue() : target;
switch (type) {
case 'double':
return value is int ? value.toDouble() : value as double?; //使用int值初始化double时,initValue的运行时类型为int,所以进行了转换
case 'Set':
return value is Map ? value.values.toSet() : value as Set?; //扫描器获取初始值时,无法识别无类型声明的空'{}'类型,这时默认为Map类型,需要再次进行类型转换
default:
return nativeValueConverter == null ? value : nativeValueConverter!(value);
}
}