readLogic static method

dynamic readLogic(
  1. dynamic target, {
  2. String? type,
})

读取target的逻辑处理值

Implementation

static dynamic readLogic(dynamic target, {String? type}) {
  final value = target is VmObject ? target.getLogic() : 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 value;
  }
}