location_api_response.dart 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. class LocationApiResponse {
  2. final List<LocationDataFromResponse> results;
  3. LocationApiResponse({
  4. required this.results,
  5. });
  6. LocationApiResponse copyWith({
  7. required List<LocationDataFromResponse> results,
  8. }) {
  9. return LocationApiResponse(
  10. results: results,
  11. );
  12. }
  13. factory LocationApiResponse.fromMap(Map<String, dynamic> map) {
  14. return LocationApiResponse(
  15. results: (map['results']) == null
  16. ? []
  17. : List<LocationDataFromResponse>.from(
  18. (map['results']).map(
  19. (x) =>
  20. LocationDataFromResponse.fromMap(x as Map<String, dynamic>),
  21. ),
  22. ),
  23. );
  24. }
  25. }
  26. class LocationDataFromResponse {
  27. final String place;
  28. final List<double> bbox;
  29. LocationDataFromResponse({
  30. required this.place,
  31. required this.bbox,
  32. });
  33. factory LocationDataFromResponse.fromMap(Map<String, dynamic> map) {
  34. return LocationDataFromResponse(
  35. place: map['place'] as String,
  36. bbox: List<double>.from(
  37. (map['bbox']),
  38. ),
  39. );
  40. }
  41. }