From cf455db7e032276500f2d02b013ac7d338285f6f Mon Sep 17 00:00:00 2001 From: Victor Porton Date: Thu, 9 Feb 2023 12:41:09 +0200 Subject: [PATCH] T? for result --- example/places_autocomplete.dart | 6 +++--- lib/src/core.dart | 2 +- lib/src/places.dart | 2 +- lib/src/places.g.dart | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/places_autocomplete.dart b/example/places_autocomplete.dart index 3912e81..0e93728 100644 --- a/example/places_autocomplete.dart +++ b/example/places_autocomplete.dart @@ -26,9 +26,9 @@ Future main() async { ); print('\nDetails :'); - print(details.result.formattedAddress); - print(details.result.formattedPhoneNumber); - print(details.result.url); + print(details.result!.formattedAddress); + print(details.result!.formattedPhoneNumber); + print(details.result!.url); } else { print(res.errorMessage); } diff --git a/lib/src/core.dart b/lib/src/core.dart index a01c078..900c848 100644 --- a/lib/src/core.dart +++ b/lib/src/core.dart @@ -98,7 +98,7 @@ abstract class GoogleResponseList extends GoogleResponseStatus { } abstract class GoogleResponse extends GoogleResponseStatus { - final T result; + final T? result; GoogleResponse(String status, String? errorMessage, this.result) : super(status: status, errorMessage: errorMessage); diff --git a/lib/src/places.dart b/lib/src/places.dart index 7eb8933..170fffc 100644 --- a/lib/src/places.dart +++ b/lib/src/places.dart @@ -818,7 +818,7 @@ enum PriceLevel { @JsonSerializable() class PlacesDetailsResponse extends GoogleResponseStatus { - final PlaceDetails result; + final PlaceDetails? result; /// JSON html_attributions @JsonKey(defaultValue: []) diff --git a/lib/src/places.g.dart b/lib/src/places.g.dart index b7a3fd7..d564d17 100644 --- a/lib/src/places.g.dart +++ b/lib/src/places.g.dart @@ -291,7 +291,7 @@ PlacesDetailsResponse _$PlacesDetailsResponseFromJson( return PlacesDetailsResponse( status: json['status'] as String, errorMessage: json['error_message'] as String?, - result: PlaceDetails.fromJson(json['result'] as Map), + result: json['status'] == 'OK' ? PlaceDetails.fromJson(json['result'] as Map) : null, htmlAttributions: (json['html_attributions'] as List?) ?.map((e) => e as String) .toList() ??