conventsMap property

Map<String, Function> conventsMap
final

内置基础类型转换器

Implementation

static final Map<String, Function> conventsMap = {
  "Null=>int": (value) {
    return 0;
  },
  "Null=>double": (value) {
    return .0;
  },
  "Null=>num": (value) {
    return 0;
  },
  "Null=>bool": (value) {
    return false;
  },
  "Null=>String": (value) {
    return null;
  },
  "int=>int": (value) {
    return value;
  },
  "int=>double": (value) {
    return value;
  },
  "int=>num": (value) {
    return value;
  },
  "int=>bool": (value) {
    return value != 0 && value != null;
  },
  "int=>String": (value) {
    return value.toString();
  },
  "double=>int": (value) {
    return value.toInt();
  },
  "double=>double": (value) {
    return value;
  },
  "double=>num": (value) {
    return value;
  },
  "double=>bool": (value) {
    return value != 0.0 && value != null;
  },
  "double=>String": (value) {
    return value.toString();
  },
  "num=>int": (value) {
    return value.toInt();
  },
  "num=>double": (value) {
    return value.toDouble();
  },
  "num=>num": (value) {
    return value;
  },
  "num=>bool": (value) {
    return value != 0 && value != null;
  },
  "num=>String": (value) {
    return value.toString();
  },
  "bool=>int": (value) {
    return 0;
  },
  "bool=>double": (value) {
    return .0;
  },
  "bool=>num": (value) {
    return 0;
  },
  "bool=>bool": (value) {
    return value;
  },
  "bool=>String": (value) {
    return value.toString();
  },
  "String=>int": (value) {
    return int.tryParse(value) ?? 0;
  },
  "String=>double": (value) {
    return double.tryParse(value) ?? .0;
  },
  "String=>num": (value) {
    return num.tryParse(value) ?? 0;
  },
  "String=>bool": (value) {
    //对于 true 不区分大小相同则为true
    return true.toString() == value.toString().toLowerCase();
  },
  "String=>String": (value) {
    return value;
  },
};