resetTo method

  1. @override
void resetTo({
  1. dynamic value,
  2. dynamic justValue,
})
override

resetea los valores a partir de un map

Implementation

@override
void resetTo({value, justValue}) {
  value ??= justValue ?? {};

  for (var x in _members.values) {
    if (justValue != null && !value.containsKey(x.name)) {
      continue;
    }

    var type = value[x.name].runtimeType.toString().toLowerCase();

    if (value[x.name] is Map) {
      type = 'map';
    }
    if (value[x.name] is List) {
      type = 'list';
    }
    if (value[x.name] is List) {
      type = 'list';
    }
    if (x.type.name != type && value[x.name] != null) {
      if (!(x.type.name == 'double' && type == 'int') &&
          !(x.type.name == 'listMap' && type == 'list') &&
          !((x.type.name == 'date' || x.type.name == 'dateTime') &&
              type == 'string')) {
        console.error(
            'El tipo entrante para el campo "${x.name}" debe ser "${x.type.name}" y esta llegando "$type" en el contenedor "$label" de tipo "${runtimeType.toString()}" con valor ${x.get()}');
      }
    }

    x.resetTo(value: value[x.name]);
  }

  refresh();
}