variable_model.dart 891 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import 'basico_model.dart';
  2. import '../services/services.dart';
  3. class Variable extends Basico {
  4. String? nombre;
  5. String? clave;
  6. String? descripcion;
  7. bool? activo;
  8. Variable({
  9. super.id,
  10. this.nombre,
  11. this.clave,
  12. this.descripcion,
  13. this.activo = true,
  14. });
  15. @override
  16. Map<String, dynamic> toJson() {
  17. return {
  18. 'id': id,
  19. 'nombre': nombre,
  20. 'clave': clave,
  21. 'descripcion': descripcion,
  22. 'activo': activo == true ? 1 : 0,
  23. }..addAll(super.toJson());
  24. }
  25. Variable.fromJson(Map<String, dynamic> json) {
  26. super.parseJson(json);
  27. nombre = Basico.parseString(json['nombre']);
  28. clave = Basico.parseString(json['clave']);
  29. descripcion = Basico.parseString(json['descripcion']);
  30. activo = Basico.parseInt(json['activo']) == 1;
  31. }
  32. Future<void> guardar() async {
  33. idLocal = await RepoService().guardar(this);
  34. }
  35. }