agenda.dart 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import 'package:get/get.dart';
  2. import 'package:json_annotation/json_annotation.dart';
  3. part 'agenda.g.dart';
  4. @JsonSerializable()
  5. class Agenda {
  6. @JsonKey(name: 'id', fromJson: _intToString, toJson: _stringToInt)
  7. String id;
  8. @JsonKey(name: 'talkId')
  9. String talkId;
  10. @JsonKey(name: 'name')
  11. String? name;
  12. @JsonKey(name: 'content')
  13. Rx<String> _content = ''.obs;
  14. @JsonKey(name: 'createTime')
  15. String? createTime;
  16. @JsonKey(name: 'updateTime')
  17. String? updateTime;
  18. @JsonKey(ignore: true)
  19. RxBool todo = false.obs;
  20. @JsonKey(name: 'example')
  21. bool? isExample;
  22. @JsonKey(ignore: true)
  23. Rxn<AgendaStatus>? agendaStatus;
  24. Agenda(
  25. {required this.id,
  26. required this.talkId,
  27. this.name,
  28. this.createTime,
  29. this.updateTime,
  30. this.isExample});
  31. String get content => _content.value;
  32. set content(String newContent) {
  33. _content.value = newContent;
  34. }
  35. factory Agenda.fromJson(Map<String, dynamic> json) {
  36. final agenda = _$AgendaFromJson(json);
  37. agenda.todo.value =
  38. json.containsKey('todo') ? json['todo'] as bool? ?? false : false;
  39. agenda.agendaStatus = Rxn(AgendaStatus.todo);
  40. agenda._content.value = json['content'] as String? ?? '';
  41. return agenda;
  42. }
  43. static String _intToString(int value) => value.toString();
  44. static int _stringToInt(String value) => int.parse(value);
  45. }
  46. enum AgendaStatus {
  47. todo,
  48. completing,
  49. done,
  50. }