carousel.dart 981 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:sport/services/Converter.dart';
  2. /// id : 4
  3. /// type : "image"
  4. /// url : "http://4.jpg"
  5. /// position : 4
  6. /// cover : ""
  7. /// game_id : 3
  8. class Carousel {
  9. late int id;
  10. late String type;
  11. late String url;
  12. late int position;
  13. late String? cover;
  14. late int gameId;
  15. Map<String, dynamic> toMap() {
  16. return {
  17. 'id': this.id,
  18. 'type': this.type,
  19. 'url': this.url,
  20. 'position': this.position,
  21. 'cover': this.cover,
  22. 'game_id': this.gameId,
  23. };
  24. }
  25. factory Carousel.fromMap(Map<String, dynamic> map) {
  26. return Carousel(
  27. id: map['id'] as int,
  28. type: map['type'] as String,
  29. url: map['url'] as String,
  30. position: map['position'] as int,
  31. cover: map['cover'] as String,
  32. gameId: Converter.toInt(map['game_id']),
  33. );
  34. }
  35. Carousel({
  36. required this.id,
  37. required this.type,
  38. required this.url,
  39. required this.position,
  40. required this.cover,
  41. required this.gameId,
  42. });
  43. }