step_realtime_entity.dart 928 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import 'dart:convert';
  2. import 'package:sport/generated/json/base/json_field.dart';
  3. import 'package:sport/generated/json/step_realtime_entity.g.dart';
  4. @JsonSerializable()
  5. class StepRealtimeEntity {
  6. late int id;
  7. @JSONField(name: "user_id")
  8. late int userId;
  9. late int start;
  10. late int end;
  11. late int step;
  12. late int motion;
  13. late int type;
  14. late int target;
  15. late int year = 0;
  16. late String data;
  17. StepRealtimeEntity();
  18. factory StepRealtimeEntity.fromJson(Map<String, dynamic> json) => $StepRealtimeEntityFromJson(json);
  19. Map<String, dynamic> toJson() => $StepRealtimeEntityToJson(this);
  20. @override
  21. String toString() {
  22. return jsonEncode(this);
  23. }
  24. List<List<int>> get motionData {
  25. List<List<int>> data = [];
  26. List<dynamic> v = json.decode(this.data);
  27. v.forEach((element) {
  28. List<int> value = [];
  29. element.forEach((vv) {
  30. value.add(vv as int);
  31. });
  32. data.add(value);
  33. });
  34. return data;
  35. }
  36. }