diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..cb72314 --- /dev/null +++ b/build.yaml @@ -0,0 +1,11 @@ +targets: + $default: + builders: + json_serializable: + options: + # Options configure how source code is generated for every + # `@JsonSerializable`-annotated class in the package. + # + # The default value for each is listed. + any_map: true + explicit_to_json: true \ No newline at end of file diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..4f8d4d2 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 11.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index d59cc08..f683e9f 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -135,7 +135,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -280,7 +280,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -362,7 +362,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -411,7 +411,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..3db53b6 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/example/pubspec.lock b/example/pubspec.lock index 2215551..e0747f6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,13 +1,34 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "49.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -15,13 +36,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -29,20 +64,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" cupertino_icons: dependency: "direct main" description: @@ -50,13 +106,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.4" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" flutter: dependency: "direct main" description: flutter @@ -74,6 +144,13 @@ packages: description: flutter source: sdk version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" google_place: dependency: "direct main" description: @@ -95,27 +172,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" + json_annotation: + dependency: transitive + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.7.0" + json_serializable: + dependency: transitive + description: + name: json_serializable + url: "https://pub.dartlang.org" + source: hosted + version: "6.5.2" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" pedantic: dependency: transitive description: @@ -123,18 +235,46 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.11.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.6" + source_helper: + dependency: transitive + description: + name: source_helper + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.3" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -155,21 +295,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.12" typed_data: dependency: transitive description: @@ -183,6 +323,20 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.18.0 <3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 90933e5..139825b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -20,5 +20,4 @@ dev_dependencies: flutter: uses-material-design: true assets: - - assets/ - - .env + - assets/ \ No newline at end of file diff --git a/lib/google_place.dart b/lib/google_place.dart index d26814d..e0a4f22 100644 --- a/lib/google_place.dart +++ b/lib/google_place.dart @@ -62,7 +62,7 @@ class GooglePlace { late QueryAutocomplete queryAutocomplete; /// [timeout] timeout for http call. - static Duration timeout = Duration(milliseconds: 1500); + static Duration timeout = Duration(milliseconds: 3000); /// Optional headers to pass on each request final Map headers; diff --git a/lib/src/autocomplete/autocomplete_prediction.dart b/lib/src/autocomplete/autocomplete_prediction.dart index d4828f9..afae3d0 100644 --- a/lib/src/autocomplete/autocomplete_prediction.dart +++ b/lib/src/autocomplete/autocomplete_prediction.dart @@ -1,7 +1,11 @@ import 'package:google_place/src/models/matched_substring.dart'; import 'package:google_place/src/models/structured_formatting.dart'; import 'package:google_place/src/models/term.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'autocomplete_prediction.g.dart'; + +@JsonSerializable() class AutocompletePrediction { /// [description] contains the human-readable name for the returned result. For establishment results, this is usually /// the business name. @@ -10,6 +14,7 @@ class AutocompletePrediction { /// [distanceMeters] contains an integer indicating the straight-line distance between the predicted place, /// and the specified origin point, in meters. This field is only returned when the origin point is specified in the request. /// This field is not returned in predictions of type route. + @JsonKey(name: "distance_meters") final int? distanceMeters; /// [id] contains id. @@ -17,16 +22,19 @@ class AutocompletePrediction { /// [matchedSubstrings] contains an array with offset value and length. These describe the location of the entered term in /// the prediction result text, so that the term can be highlighted if desired. + @JsonKey(name: "matched_substrings") final List? matchedSubstrings; /// [placeId] is a textual identifier that uniquely identifies a place. To retrieve information about the place, /// pass this identifier in the placeId field of a Places API request. For more information about place IDs. + @JsonKey(name: "place_id") final String? placeId; /// [reference] contains reference. final String? reference; /// [structuredFormatting] provides pre-formatted text that can be shown in your autocomplete results + @JsonKey(name: "structured_formatting") final StructuredFormatting? structuredFormatting; /// contains an array of terms identifying each section of the returned description @@ -49,27 +57,8 @@ class AutocompletePrediction { this.types, }); - factory AutocompletePrediction.fromJson(Map json) { - return AutocompletePrediction( - description: json['description'] as String?, - distanceMeters: json['distance_meters'] as int?, - id: json['id'] as String?, - matchedSubstrings: json['matched_substrings'] != null - ? json['matched_substrings'] - .map((json) => MatchedSubstring.fromJson(json)) - .toList() - : null, - placeId: json['place_id'] as String?, - reference: json['reference'] as String?, - structuredFormatting: json['structured_formatting'] != null - ? StructuredFormatting.fromJson(json['structured_formatting']) - : null, - terms: json['terms'] != null - ? json['terms'].map((json) => Term.fromJson(json)).toList() - : null, - types: json['types'] != null - ? (json['types'] as List).cast() - : null, - ); - } + factory AutocompletePrediction.fromJson(Map json) => + _$AutocompletePredictionFromJson(json); + + Map toJson() => _$AutocompletePredictionToJson(this); } diff --git a/lib/src/autocomplete/autocomplete_prediction.g.dart b/lib/src/autocomplete/autocomplete_prediction.g.dart new file mode 100644 index 0000000..4c0b87d --- /dev/null +++ b/lib/src/autocomplete/autocomplete_prediction.g.dart @@ -0,0 +1,44 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'autocomplete_prediction.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +AutocompletePrediction _$AutocompletePredictionFromJson(Map json) => + AutocompletePrediction( + description: json['description'] as String?, + distanceMeters: json['distance_meters'] as int?, + id: json['id'] as String?, + matchedSubstrings: (json['matched_substrings'] as List?) + ?.map((e) => + MatchedSubstring.fromJson(Map.from(e as Map))) + .toList(), + placeId: json['place_id'] as String?, + reference: json['reference'] as String?, + structuredFormatting: json['structured_formatting'] == null + ? null + : StructuredFormatting.fromJson( + Map.from(json['structured_formatting'] as Map)), + terms: (json['terms'] as List?) + ?.map((e) => Term.fromJson(Map.from(e as Map))) + .toList(), + types: + (json['types'] as List?)?.map((e) => e as String).toList(), + ); + +Map _$AutocompletePredictionToJson( + AutocompletePrediction instance) => + { + 'description': instance.description, + 'distance_meters': instance.distanceMeters, + 'id': instance.id, + 'matched_substrings': + instance.matchedSubstrings?.map((e) => e.toJson()).toList(), + 'place_id': instance.placeId, + 'reference': instance.reference, + 'structured_formatting': instance.structuredFormatting?.toJson(), + 'terms': instance.terms?.map((e) => e.toJson()).toList(), + 'types': instance.types, + }; diff --git a/lib/src/autocomplete/autocomplete_response.dart b/lib/src/autocomplete/autocomplete_response.dart index 7490aba..3e0c72d 100644 --- a/lib/src/autocomplete/autocomplete_response.dart +++ b/lib/src/autocomplete/autocomplete_response.dart @@ -1,25 +1,22 @@ import 'dart:convert'; import 'package:google_place/src/autocomplete/autocomplete_prediction.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'autocomplete_response.g.dart'; /// The Autocomplete response contains place predictions and status +@JsonSerializable() class AutocompleteResponse { final String? status; final List? predictions; AutocompleteResponse({this.status, this.predictions}); - factory AutocompleteResponse.fromJson(Map json) { - return AutocompleteResponse( - status: json['status'] as String?, - predictions: json['predictions'] != null - ? json['predictions'] - .map( - (json) => AutocompletePrediction.fromJson(json)) - .toList() - : null, - ); - } + factory AutocompleteResponse.fromJson(Map json) => + _$AutocompleteResponseFromJson(json); + + Map toJson() => _$AutocompleteResponseToJson(this); static AutocompleteResponse parseAutocompleteResult(String responseBody) { final parsed = json.decode(responseBody).cast(); diff --git a/lib/src/autocomplete/autocomplete_response.g.dart b/lib/src/autocomplete/autocomplete_response.g.dart new file mode 100644 index 0000000..def30e1 --- /dev/null +++ b/lib/src/autocomplete/autocomplete_response.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'autocomplete_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +AutocompleteResponse _$AutocompleteResponseFromJson(Map json) => + AutocompleteResponse( + status: json['status'] as String?, + predictions: (json['predictions'] as List?) + ?.map((e) => AutocompletePrediction.fromJson( + Map.from(e as Map))) + .toList(), + ); + +Map _$AutocompleteResponseToJson( + AutocompleteResponse instance) => + { + 'status': instance.status, + 'predictions': instance.predictions?.map((e) => e.toJson()).toList(), + }; diff --git a/lib/src/details/details_response.dart b/lib/src/details/details_response.dart index 0781cc7..0bcc269 100644 --- a/lib/src/details/details_response.dart +++ b/lib/src/details/details_response.dart @@ -1,10 +1,15 @@ import 'dart:convert'; import 'package:google_place/src/details/details_result.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'details_response.g.dart'; /// The Details response contains html Attributions and details and status +@JsonSerializable() class DetailsResponse { final String? status; + @JsonKey(name: "html_attributions") final List? htmlAttributions; final DetailsResult? result; @@ -13,18 +18,10 @@ class DetailsResponse { this.htmlAttributions, this.result, }); + factory DetailsResponse.fromJson(Map json) => + _$DetailsResponseFromJson(json); - factory DetailsResponse.fromJson(Map json) { - return DetailsResponse( - status: json['status'], - htmlAttributions: json['html_attributions'] != null - ? (json['html_attributions'] as List).cast() - : null, - result: json['result'] != null - ? DetailsResult.fromJson(json['result']) - : null, - ); - } + Map toJson() => _$DetailsResponseToJson(this); static DetailsResponse parseDetailsResult(String responseBody) { final parsed = json.decode(responseBody).cast(); diff --git a/lib/src/details/details_response.g.dart b/lib/src/details/details_response.g.dart new file mode 100644 index 0000000..14e30a2 --- /dev/null +++ b/lib/src/details/details_response.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'details_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DetailsResponse _$DetailsResponseFromJson(Map json) => DetailsResponse( + status: json['status'] as String?, + htmlAttributions: (json['html_attributions'] as List?) + ?.map((e) => e as String) + .toList(), + result: json['result'] == null + ? null + : DetailsResult.fromJson( + Map.from(json['result'] as Map)), + ); + +Map _$DetailsResponseToJson(DetailsResponse instance) => + { + 'status': instance.status, + 'html_attributions': instance.htmlAttributions, + 'result': instance.result?.toJson(), + }; diff --git a/lib/src/details/details_result.dart b/lib/src/details/details_result.dart index 5f157c8..7e805f6 100644 --- a/lib/src/details/details_result.dart +++ b/lib/src/details/details_result.dart @@ -4,9 +4,14 @@ import 'package:google_place/src/models/opening_hours.dart'; import 'package:google_place/src/models/photo.dart'; import 'package:google_place/src/models/plus_code.dart'; import 'package:google_place/src/models/review.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'details_result.g.dart'; + +@JsonSerializable() class DetailsResult { /// [addressComponents] is an array containing the separate components applicable to this address. + @JsonKey(name: "address_components") final List? addressComponents; /// [businessStatus] indicates the operational status of the place, if it is a business. @@ -14,16 +19,20 @@ class DetailsResult { /// OPERATIONAL /// CLOSED_TEMPORARILY /// CLOSED_PERMANENTLY + @JsonKey(name: "business_status") final String? businessStatus; /// [adrAddress] is a representation of the place's address in the adr microformat. + @JsonKey(name: "adr_address") final String? adrAddress; /// [formattedAddress] is a string containing the human-readable address of this place. + @JsonKey(name: "formatted_address") final String? formattedAddress; /// [formattedPhoneNumber] contains the place's phone number in its local format. For example, /// the formatted_phone_number for Google's Sydney, Australia office is (02) 9374 4000. + @JsonKey(name: "formatted_phone_number") final String? formattedPhoneNumber; /// [geometry] contains Geometry object. @@ -38,6 +47,7 @@ class DetailsResult { /// [internationalPhoneNumber] contains the place's phone number in international format. /// International format includes the country code, and is prefixed with the plus (+) sign. /// For example, the international_phone_number for Google's Sydney, Australia office is +61 2 9374 4000. + @JsonKey(name: "international_phone_number") final String? internationalPhoneNumber; /// [name] contains the human-readable name for the returned result. For establishment results, @@ -45,6 +55,7 @@ class DetailsResult { final String? name; /// [geometry] contains OpeningHours object. + @JsonKey(name: "opening_hours") final OpeningHours? openingHours; /// [photos] an array of photo objects, each containing a reference to an image. @@ -52,12 +63,14 @@ class DetailsResult { /// [placeId] A textual identifier that uniquely identifies a place. To retrieve information about the place, /// pass this identifier in the placeId field of a Places API request. For more information about place IDs. + @JsonKey(name: "place_id") final String? placeId; /// [plusCode] is an encoded location reference, derived from latitude and longitude coordinates, /// that represents an area: 1/8000th of a degree by 1/8000th of a degree (about 14m x 14m at the equator) or smaller. /// Plus codes can be used as a replacement for street addresses in places where they do not exist /// (where buildings are not numbered or streets are not named). + @JsonKey(name: "plus_code") final PlusCode? plusCode; /// [rating] contains the place's rating, from 1.0 to 5.0, based on aggregated user reviews. @@ -83,11 +96,13 @@ class DetailsResult { final String? url; /// [userRatingsTotal] is user ratings total. + @JsonKey(name: "user_ratings_total") final int? userRatingsTotal; /// [utcOffset] contains the number of minutes this place’s current timezone is offset from UTC. /// For example, for places in Sydney, Australia during daylight saving time this would be 660 /// (+11 hours from UTC), and for places in California outside of daylight saving time this would be -480 (-8 hours from UTC). + @JsonKey(name: "utc_offset") final int? utcOffset; /// [vicinity] lists a simplified address for the place, including the street name, street number, and locality, @@ -105,12 +120,14 @@ class DetailsResult { /// 2 — Moderate /// 3 — Expensive /// 4 — Very Expensive + @JsonKey(name: "price_level") final int? priceLevel; /// [permanentlyClosed] is a boolean flag indicating whether the place has shut down either permanently /// or temporarily (value true). If the place is operational, or if no data is available, the flag is absent from the response. @Deprecated( 'permanently_closed is now deprecated. Instead, use business_status to get the operational status of businesses.') + @JsonKey(name: "permanently_closed") final bool? permanentlyClosed; DetailsResult({ @@ -142,51 +159,8 @@ class DetailsResult { this.permanentlyClosed, }); - factory DetailsResult.fromJson(Map json) { - return DetailsResult( - addressComponents: json['address_components'] != null - ? json['address_components'] - .map((json) => AddressComponent.fromJson(json)) - .toList() - : null, - businessStatus: json['business_status'], - adrAddress: json['adr_address'], - formattedAddress: json['formatted_address'], - formattedPhoneNumber: json['formatted_phone_number'], - geometry: - json['geometry'] != null ? Geometry.fromJson(json['geometry']) : null, - icon: json['icon'], - id: json['id'], - internationalPhoneNumber: json['international_phone_number'], - name: json['name'], - openingHours: json['opening_hours'] != null - ? OpeningHours.fromJson(json['opening_hours']) - : null, - photos: json['photos'] != null - ? json['photos'].map((json) => Photo.fromJson(json)).toList() - : null, - placeId: json['place_id'], - plusCode: json['plus_code'] != null - ? PlusCode.fromJson(json['plus_code']) - : null, - rating: json['rating'] != null ? json['rating'].toDouble() : null, - reference: json['reference'], - reviews: json['reviews'] != null - ? json['reviews'] - .map((json) => Review.fromJson(json)) - .toList() - : null, - scope: json['scope'], - types: json['types'] != null - ? (json['types'] as List).cast() - : null, - url: json['url'], - userRatingsTotal: json['user_ratings_total'], - utcOffset: json['utc_offset'], - vicinity: json['vicinity'], - website: json['website'], - priceLevel: json['price_level'], - permanentlyClosed: json['permanently_closed'], - ); - } + factory DetailsResult.fromJson(Map json) => + _$DetailsResultFromJson(json); + + Map toJson() => _$DetailsResultToJson(this); } diff --git a/lib/src/details/details_result.g.dart b/lib/src/details/details_result.g.dart new file mode 100644 index 0000000..fac06d7 --- /dev/null +++ b/lib/src/details/details_result.g.dart @@ -0,0 +1,84 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'details_result.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DetailsResult _$DetailsResultFromJson(Map json) => DetailsResult( + addressComponents: (json['address_components'] as List?) + ?.map((e) => + AddressComponent.fromJson(Map.from(e as Map))) + .toList(), + businessStatus: json['business_status'] as String?, + adrAddress: json['adr_address'] as String?, + formattedAddress: json['formatted_address'] as String?, + formattedPhoneNumber: json['formatted_phone_number'] as String?, + geometry: json['geometry'] == null + ? null + : Geometry.fromJson( + Map.from(json['geometry'] as Map)), + icon: json['icon'] as String?, + id: json['id'] as String?, + internationalPhoneNumber: json['international_phone_number'] as String?, + name: json['name'] as String?, + openingHours: json['opening_hours'] == null + ? null + : OpeningHours.fromJson( + Map.from(json['opening_hours'] as Map)), + photos: (json['photos'] as List?) + ?.map((e) => Photo.fromJson(Map.from(e as Map))) + .toList(), + placeId: json['place_id'] as String?, + plusCode: json['plus_code'] == null + ? null + : PlusCode.fromJson( + Map.from(json['plus_code'] as Map)), + rating: (json['rating'] as num?)?.toDouble(), + reference: json['reference'] as String?, + reviews: (json['reviews'] as List?) + ?.map((e) => Review.fromJson(Map.from(e as Map))) + .toList(), + scope: json['scope'] as String?, + types: + (json['types'] as List?)?.map((e) => e as String).toList(), + url: json['url'] as String?, + userRatingsTotal: json['user_ratings_total'] as int?, + utcOffset: json['utc_offset'] as int?, + vicinity: json['vicinity'] as String?, + website: json['website'] as String?, + priceLevel: json['price_level'] as int?, + permanentlyClosed: json['permanently_closed'] as bool?, + ); + +Map _$DetailsResultToJson(DetailsResult instance) => + { + 'address_components': + instance.addressComponents?.map((e) => e.toJson()).toList(), + 'business_status': instance.businessStatus, + 'adr_address': instance.adrAddress, + 'formatted_address': instance.formattedAddress, + 'formatted_phone_number': instance.formattedPhoneNumber, + 'geometry': instance.geometry?.toJson(), + 'icon': instance.icon, + 'id': instance.id, + 'international_phone_number': instance.internationalPhoneNumber, + 'name': instance.name, + 'opening_hours': instance.openingHours?.toJson(), + 'photos': instance.photos?.map((e) => e.toJson()).toList(), + 'place_id': instance.placeId, + 'plus_code': instance.plusCode?.toJson(), + 'rating': instance.rating, + 'reference': instance.reference, + 'reviews': instance.reviews?.map((e) => e.toJson()).toList(), + 'scope': instance.scope, + 'types': instance.types, + 'url': instance.url, + 'user_ratings_total': instance.userRatingsTotal, + 'utc_offset': instance.utcOffset, + 'vicinity': instance.vicinity, + 'website': instance.website, + 'price_level': instance.priceLevel, + 'permanently_closed': instance.permanentlyClosed, + }; diff --git a/lib/src/models/address_component.dart b/lib/src/models/address_component.dart index 1e8abe4..c796c0d 100644 --- a/lib/src/models/address_component.dart +++ b/lib/src/models/address_component.dart @@ -1,10 +1,17 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'address_component.g.dart'; + +@JsonSerializable() class AddressComponent { /// [longName] is the full text description or name of the address component as returned by the Geocoder. + @JsonKey(name: "long_name") final String? longName; /// [shortName] is an abbreviated textual name for the address component, if available. /// For example, an address component for the state of Alaska may have a long_name of "Alaska" /// and a short_name of "AK" using the 2-letter postal abbreviation. + @JsonKey(name: "short_name") final String? shortName; /// [types] is an array indicating the type of the address component. @@ -16,13 +23,8 @@ class AddressComponent { this.types, }); - factory AddressComponent.fromJson(Map json) { - return AddressComponent( - longName: json['long_name'], - shortName: json['short_name'], - types: json['types'] != null - ? (json['types'] as List).cast() - : null, - ); - } + factory AddressComponent.fromJson(Map json) => + _$AddressComponentFromJson(json); + + Map toJson() => _$AddressComponentToJson(this); } diff --git a/lib/src/models/address_component.g.dart b/lib/src/models/address_component.g.dart new file mode 100644 index 0000000..b27f2c5 --- /dev/null +++ b/lib/src/models/address_component.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'address_component.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +AddressComponent _$AddressComponentFromJson(Map json) => AddressComponent( + longName: json['long_name'] as String?, + shortName: json['short_name'] as String?, + types: + (json['types'] as List?)?.map((e) => e as String).toList(), + ); + +Map _$AddressComponentToJson(AddressComponent instance) => + { + 'long_name': instance.longName, + 'short_name': instance.shortName, + 'types': instance.types, + }; diff --git a/lib/src/models/bounds.dart b/lib/src/models/bounds.dart index b4df793..72ccbce 100644 --- a/lib/src/models/bounds.dart +++ b/lib/src/models/bounds.dart @@ -1,20 +1,17 @@ import 'package:google_place/src/models/northeast.dart'; import 'package:google_place/src/models/southwest.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'bounds.g.dart'; + +@JsonSerializable() class Bounds { final Northeast? northeast; final Southwest? southwest; Bounds({this.northeast, this.southwest}); - factory Bounds.fromJson(Map json) { - return Bounds( - northeast: json['northeast'] != null - ? Northeast.fromJson(json['northeast']) - : null, - southwest: json['southwest'] != null - ? Southwest.fromJson(json['southwest']) - : null, - ); - } + factory Bounds.fromJson(Map json) => _$BoundsFromJson(json); + + Map toJson() => _$BoundsToJson(this); } diff --git a/lib/src/models/bounds.g.dart b/lib/src/models/bounds.g.dart new file mode 100644 index 0000000..b8de783 --- /dev/null +++ b/lib/src/models/bounds.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'bounds.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Bounds _$BoundsFromJson(Map json) => Bounds( + northeast: json['northeast'] == null + ? null + : Northeast.fromJson( + Map.from(json['northeast'] as Map)), + southwest: json['southwest'] == null + ? null + : Southwest.fromJson( + Map.from(json['southwest'] as Map)), + ); + +Map _$BoundsToJson(Bounds instance) => { + 'northeast': instance.northeast?.toJson(), + 'southwest': instance.southwest?.toJson(), + }; diff --git a/lib/src/models/close.dart b/lib/src/models/close.dart index 17b8c8e..3eb286c 100644 --- a/lib/src/models/close.dart +++ b/lib/src/models/close.dart @@ -1,3 +1,8 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'close.g.dart'; + +@JsonSerializable() class Close { /// [day] a number from 0–6, corresponding to the days of the week, starting on Sunday. For example, 2 means Tuesday. final int? day; @@ -8,10 +13,7 @@ class Close { Close({this.day, this.time}); - factory Close.fromJson(Map json) { - return Close( - day: json['day'], - time: json['time'], - ); - } + factory Close.fromJson(Map json) => _$CloseFromJson(json); + + Map toJson() => _$CloseToJson(this); } diff --git a/lib/src/models/close.g.dart b/lib/src/models/close.g.dart new file mode 100644 index 0000000..35070e9 --- /dev/null +++ b/lib/src/models/close.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'close.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Close _$CloseFromJson(Map json) => Close( + day: json['day'] as int?, + time: json['time'] as String?, + ); + +Map _$CloseToJson(Close instance) => { + 'day': instance.day, + 'time': instance.time, + }; diff --git a/lib/src/models/component.dart b/lib/src/models/component.dart index 488daa4..6a5b36d 100644 --- a/lib/src/models/component.dart +++ b/lib/src/models/component.dart @@ -1,6 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'component.g.dart'; + +@JsonSerializable() class Component { final String component; final String value; Component(this.component, this.value); + + factory Component.fromJson(Map json) => + _$ComponentFromJson(json); + + Map toJson() => _$ComponentToJson(this); } diff --git a/lib/src/models/component.g.dart b/lib/src/models/component.g.dart new file mode 100644 index 0000000..31850fc --- /dev/null +++ b/lib/src/models/component.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'component.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Component _$ComponentFromJson(Map json) => Component( + json['component'] as String, + json['value'] as String, + ); + +Map _$ComponentToJson(Component instance) => { + 'component': instance.component, + 'value': instance.value, + }; diff --git a/lib/src/models/debug_log.dart b/lib/src/models/debug_log.dart index b3084ec..ba2e461 100644 --- a/lib/src/models/debug_log.dart +++ b/lib/src/models/debug_log.dart @@ -1,13 +1,15 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'debug_log.g.dart'; + +@JsonSerializable() class DebugLog { final List? line; DebugLog({this.line}); - factory DebugLog.fromJson(Map json) { - return DebugLog( - line: json['line'] != null - ? (json['line'] as List).cast() - : null, - ); - } + factory DebugLog.fromJson(Map json) => + _$DebugLogFromJson(json); + + Map toJson() => _$DebugLogToJson(this); } diff --git a/lib/src/models/debug_log.g.dart b/lib/src/models/debug_log.g.dart new file mode 100644 index 0000000..afc2bef --- /dev/null +++ b/lib/src/models/debug_log.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'debug_log.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DebugLog _$DebugLogFromJson(Map json) => DebugLog( + line: (json['line'] as List?)?.map((e) => e as String).toList(), + ); + +Map _$DebugLogToJson(DebugLog instance) => { + 'line': instance.line, + }; diff --git a/lib/src/models/geometry.dart b/lib/src/models/geometry.dart index 0c1f64e..7cd8033 100644 --- a/lib/src/models/geometry.dart +++ b/lib/src/models/geometry.dart @@ -1,7 +1,11 @@ import 'package:google_place/src/models/bounds.dart'; import 'package:google_place/src/models/location.dart'; import 'package:google_place/src/models/viewport.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'geometry.g.dart'; + +@JsonSerializable() class Geometry { /// [location] contains the geocoded latitude,longitude value for this place. final Location? location; @@ -14,13 +18,8 @@ class Geometry { Geometry({this.location, this.viewport, this.bounds}); - factory Geometry.fromJson(Map json) { - return Geometry( - location: - json['location'] != null ? Location.fromJson(json['location']) : null, - viewport: - json['viewport'] != null ? Viewport.fromJson(json['viewport']) : null, - bounds: json['bounds'] != null ? Bounds.fromJson(json['bounds']) : null, - ); - } + factory Geometry.fromJson(Map json) => + _$GeometryFromJson(json); + + Map toJson() => _$GeometryToJson(this); } diff --git a/lib/src/models/geometry.g.dart b/lib/src/models/geometry.g.dart new file mode 100644 index 0000000..c7baf18 --- /dev/null +++ b/lib/src/models/geometry.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'geometry.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Geometry _$GeometryFromJson(Map json) => Geometry( + location: json['location'] == null + ? null + : Location.fromJson( + Map.from(json['location'] as Map)), + viewport: json['viewport'] == null + ? null + : Viewport.fromJson( + Map.from(json['viewport'] as Map)), + bounds: json['bounds'] == null + ? null + : Bounds.fromJson(Map.from(json['bounds'] as Map)), + ); + +Map _$GeometryToJson(Geometry instance) => { + 'location': instance.location?.toJson(), + 'viewport': instance.viewport?.toJson(), + 'bounds': instance.bounds?.toJson(), + }; diff --git a/lib/src/models/lat_lon.dart b/lib/src/models/lat_lon.dart index 6343dd3..28fd769 100644 --- a/lib/src/models/lat_lon.dart +++ b/lib/src/models/lat_lon.dart @@ -1,4 +1,10 @@ +import 'package:json_annotation/json_annotation.dart'; + /// A pair of latitude and longitude coordinates, stored as degrees. + +part 'lat_lon.g.dart'; + +@JsonSerializable() class LatLon { /// Creates a geographical location specified in degrees [latitude] and /// [longitude]. @@ -20,4 +26,8 @@ class LatLon { @override String toString() => '$runtimeType($latitude, $longitude)'; + + factory LatLon.fromJson(Map json) => _$LatLonFromJson(json); + + Map toJson() => _$LatLonToJson(this); } diff --git a/lib/src/models/lat_lon.g.dart b/lib/src/models/lat_lon.g.dart new file mode 100644 index 0000000..21ef678 --- /dev/null +++ b/lib/src/models/lat_lon.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'lat_lon.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +LatLon _$LatLonFromJson(Map json) => LatLon( + (json['latitude'] as num).toDouble(), + (json['longitude'] as num).toDouble(), + ); + +Map _$LatLonToJson(LatLon instance) => { + 'latitude': instance.latitude, + 'longitude': instance.longitude, + }; diff --git a/lib/src/models/location.dart b/lib/src/models/location.dart index 76ad6f2..b2766da 100644 --- a/lib/src/models/location.dart +++ b/lib/src/models/location.dart @@ -1,13 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'location.g.dart'; + +@JsonSerializable() class Location { final double? lat; final double? lng; Location({this.lat, this.lng}); - factory Location.fromJson(Map json) { - return Location( - lat: json['lat'] != null ? json['lat'].toDouble() : null, - lng: json['lng'] != null ? json['lng'].toDouble() : null, - ); - } + factory Location.fromJson(Map json) => + _$LocationFromJson(json); + + Map toJson() => _$LocationToJson(this); } diff --git a/lib/src/models/location.g.dart b/lib/src/models/location.g.dart new file mode 100644 index 0000000..8bb3f8c --- /dev/null +++ b/lib/src/models/location.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'location.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Location _$LocationFromJson(Map json) => Location( + lat: (json['lat'] as num?)?.toDouble(), + lng: (json['lng'] as num?)?.toDouble(), + ); + +Map _$LocationToJson(Location instance) => { + 'lat': instance.lat, + 'lng': instance.lng, + }; diff --git a/lib/src/models/locationbias.dart b/lib/src/models/locationbias.dart index a051f37..20c90ea 100644 --- a/lib/src/models/locationbias.dart +++ b/lib/src/models/locationbias.dart @@ -1,8 +1,13 @@ import 'package:google_place/src/models/lat_lon.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'locationbias.g.dart'; /// [Locationbias] - Prefer results in a specified area, by specifying either a radius plus lat/lng, /// or two lat/lng pairs representing the points of a rectangle. /// If this parameter is not specified, the API uses IP address biasing by default. + +@JsonSerializable() class Locationbias { /// [ipbias] - Instructs the API to use IP address biasing. final bool? ipbias; @@ -41,18 +46,35 @@ class Locationbias { if (ipbias == null || ipbias!) assert(point != null && circular != null && rectangular != null); } + factory Locationbias.fromJson(Map json) => + _$LocationbiasFromJson(json); + + Map toJson() => _$LocationbiasToJson(this); } +@JsonSerializable() class Circular { final int radius; + @JsonKey(name: "lat_lng") final LatLon latLng; Circular(this.radius, this.latLng); + factory Circular.fromJson(Map json) => + _$CircularFromJson(json); + + Map toJson() => _$CircularToJson(this); } +@JsonSerializable() class Rectangular { + @JsonKey(name: "south_west") final LatLon southWest; + @JsonKey(name: "north_east") final LatLon northEast; Rectangular(this.southWest, this.northEast); + factory Rectangular.fromJson(Map json) => + _$RectangularFromJson(json); + + Map toJson() => _$RectangularToJson(this); } diff --git a/lib/src/models/locationbias.g.dart b/lib/src/models/locationbias.g.dart new file mode 100644 index 0000000..c4901bf --- /dev/null +++ b/lib/src/models/locationbias.g.dart @@ -0,0 +1,51 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'locationbias.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Locationbias _$LocationbiasFromJson(Map json) => Locationbias( + ipbias: json['ipbias'] as bool?, + point: json['point'] == null + ? null + : LatLon.fromJson(Map.from(json['point'] as Map)), + circular: json['circular'] == null + ? null + : Circular.fromJson( + Map.from(json['circular'] as Map)), + rectangular: json['rectangular'] == null + ? null + : Rectangular.fromJson( + Map.from(json['rectangular'] as Map)), + ); + +Map _$LocationbiasToJson(Locationbias instance) => + { + 'ipbias': instance.ipbias, + 'point': instance.point?.toJson(), + 'circular': instance.circular?.toJson(), + 'rectangular': instance.rectangular?.toJson(), + }; + +Circular _$CircularFromJson(Map json) => Circular( + json['radius'] as int, + LatLon.fromJson(Map.from(json['lat_lng'] as Map)), + ); + +Map _$CircularToJson(Circular instance) => { + 'radius': instance.radius, + 'lat_lng': instance.latLng.toJson(), + }; + +Rectangular _$RectangularFromJson(Map json) => Rectangular( + LatLon.fromJson(Map.from(json['south_west'] as Map)), + LatLon.fromJson(Map.from(json['north_east'] as Map)), + ); + +Map _$RectangularToJson(Rectangular instance) => + { + 'south_west': instance.southWest.toJson(), + 'north_east': instance.northEast.toJson(), + }; diff --git a/lib/src/models/main_text_matched_substring.dart b/lib/src/models/main_text_matched_substring.dart index f9013f9..fec06b0 100644 --- a/lib/src/models/main_text_matched_substring.dart +++ b/lib/src/models/main_text_matched_substring.dart @@ -1,13 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'main_text_matched_substring.g.dart'; + +@JsonSerializable() class MainTextMatchedSubstring { final int? length; final int? offset; MainTextMatchedSubstring({this.length, this.offset}); - factory MainTextMatchedSubstring.fromJson(Map json) { - return MainTextMatchedSubstring( - length: json['length'] as int?, - offset: json['offset'] as int?, - ); - } + factory MainTextMatchedSubstring.fromJson(Map json) => + _$MainTextMatchedSubstringFromJson(json); + + Map toJson() => _$MainTextMatchedSubstringToJson(this); } diff --git a/lib/src/models/main_text_matched_substring.g.dart b/lib/src/models/main_text_matched_substring.g.dart new file mode 100644 index 0000000..e50274d --- /dev/null +++ b/lib/src/models/main_text_matched_substring.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'main_text_matched_substring.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +MainTextMatchedSubstring _$MainTextMatchedSubstringFromJson(Map json) => + MainTextMatchedSubstring( + length: json['length'] as int?, + offset: json['offset'] as int?, + ); + +Map _$MainTextMatchedSubstringToJson( + MainTextMatchedSubstring instance) => + { + 'length': instance.length, + 'offset': instance.offset, + }; diff --git a/lib/src/models/matched_substring.dart b/lib/src/models/matched_substring.dart index 825dcce..7496606 100644 --- a/lib/src/models/matched_substring.dart +++ b/lib/src/models/matched_substring.dart @@ -1,13 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'matched_substring.g.dart'; + +@JsonSerializable() class MatchedSubstring { final int? length; final int? offset; MatchedSubstring({this.length, this.offset}); - factory MatchedSubstring.fromJson(Map json) { - return MatchedSubstring( - length: json['length'] as int?, - offset: json['offset'] as int?, - ); - } + factory MatchedSubstring.fromJson(Map json) => + _$MatchedSubstringFromJson(json); + + Map toJson() => _$MatchedSubstringToJson(this); } diff --git a/lib/src/models/matched_substring.g.dart b/lib/src/models/matched_substring.g.dart new file mode 100644 index 0000000..46ab701 --- /dev/null +++ b/lib/src/models/matched_substring.g.dart @@ -0,0 +1,18 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'matched_substring.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +MatchedSubstring _$MatchedSubstringFromJson(Map json) => MatchedSubstring( + length: json['length'] as int?, + offset: json['offset'] as int?, + ); + +Map _$MatchedSubstringToJson(MatchedSubstring instance) => + { + 'length': instance.length, + 'offset': instance.offset, + }; diff --git a/lib/src/models/northeast.dart b/lib/src/models/northeast.dart index 04d20f3..18304bf 100644 --- a/lib/src/models/northeast.dart +++ b/lib/src/models/northeast.dart @@ -1,13 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'northeast.g.dart'; + +@JsonSerializable() class Northeast { final double? lat; final double? lng; Northeast({this.lat, this.lng}); - factory Northeast.fromJson(Map json) { - return Northeast( - lat: json['lat'] != null ? json['lat'].toDouble() : null, - lng: json['lng'] != null ? json['lng'].toDouble() : null, - ); - } + factory Northeast.fromJson(Map json) => + _$NortheastFromJson(json); + + Map toJson() => _$NortheastToJson(this); } diff --git a/lib/src/models/northeast.g.dart b/lib/src/models/northeast.g.dart new file mode 100644 index 0000000..9ff237f --- /dev/null +++ b/lib/src/models/northeast.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'northeast.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Northeast _$NortheastFromJson(Map json) => Northeast( + lat: (json['lat'] as num?)?.toDouble(), + lng: (json['lng'] as num?)?.toDouble(), + ); + +Map _$NortheastToJson(Northeast instance) => { + 'lat': instance.lat, + 'lng': instance.lng, + }; diff --git a/lib/src/models/open.dart b/lib/src/models/open.dart index 4469d2c..f673686 100644 --- a/lib/src/models/open.dart +++ b/lib/src/models/open.dart @@ -1,3 +1,8 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'open.g.dart'; + +@JsonSerializable() class Open { /// [day] a number from 0–6, corresponding to the days of the week, starting on Sunday. For example, 2 means Tuesday. final int? day; @@ -8,10 +13,7 @@ class Open { Open({this.day, this.time}); - factory Open.fromJson(Map json) { - return Open( - day: json['day'], - time: json['time'], - ); - } + factory Open.fromJson(Map json) => _$OpenFromJson(json); + + Map toJson() => _$OpenToJson(this); } diff --git a/lib/src/models/open.g.dart b/lib/src/models/open.g.dart new file mode 100644 index 0000000..a1a8a53 --- /dev/null +++ b/lib/src/models/open.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'open.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Open _$OpenFromJson(Map json) => Open( + day: json['day'] as int?, + time: json['time'] as String?, + ); + +Map _$OpenToJson(Open instance) => { + 'day': instance.day, + 'time': instance.time, + }; diff --git a/lib/src/models/opening_hours.dart b/lib/src/models/opening_hours.dart index 4bf01d1..e633677 100644 --- a/lib/src/models/opening_hours.dart +++ b/lib/src/models/opening_hours.dart @@ -1,7 +1,12 @@ import 'package:google_place/src/models/period.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'opening_hours.g.dart'; + +@JsonSerializable() class OpeningHours { /// [openNow] is a boolean value indicating if the place is open at the current time. + @JsonKey(name: "open_now") final bool? openNow; /// [weekdayText] is an array of seven strings representing the formatted opening hours @@ -9,6 +14,7 @@ class OpeningHours { /// the Places Service will format and localize the opening hours appropriately for that language. /// The ordering of the elements in this array depends on the language parameter. /// ∂Some languages start the week on Monday while others start on Sunday. + @JsonKey(name: "weekday_text") final List? weekdayText; /// [periods] is an array of opening periods covering seven days, starting from Sunday, in chronological order. @@ -20,17 +26,8 @@ class OpeningHours { this.periods, }); - factory OpeningHours.fromJson(Map json) { - return OpeningHours( - openNow: json['open_now'], - weekdayText: json['weekday_text'] != null - ? (json['weekday_text'] as List).cast() - : null, - periods: json['periods'] != null - ? json['periods'] - .map((json) => Period.fromJson(json)) - .toList() - : null, - ); - } + factory OpeningHours.fromJson(Map json) => + _$OpeningHoursFromJson(json); + + Map toJson() => _$OpeningHoursToJson(this); } diff --git a/lib/src/models/opening_hours.g.dart b/lib/src/models/opening_hours.g.dart new file mode 100644 index 0000000..3cfe9ea --- /dev/null +++ b/lib/src/models/opening_hours.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'opening_hours.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +OpeningHours _$OpeningHoursFromJson(Map json) => OpeningHours( + openNow: json['open_now'] as bool?, + weekdayText: (json['weekday_text'] as List?) + ?.map((e) => e as String) + .toList(), + periods: (json['periods'] as List?) + ?.map((e) => Period.fromJson(Map.from(e as Map))) + .toList(), + ); + +Map _$OpeningHoursToJson(OpeningHours instance) => + { + 'open_now': instance.openNow, + 'weekday_text': instance.weekdayText, + 'periods': instance.periods?.map((e) => e.toJson()).toList(), + }; diff --git a/lib/src/models/period.dart b/lib/src/models/period.dart index 75cef25..59cd4fd 100644 --- a/lib/src/models/period.dart +++ b/lib/src/models/period.dart @@ -1,6 +1,10 @@ import 'package:google_place/src/models/close.dart'; import 'package:google_place/src/models/open.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'period.g.dart'; + +@JsonSerializable() class Period { /// [close] may contain a pair of day and time objects describing when the place closes. /// Note: If a place is always open, the close section will be missing from the response. @@ -13,10 +17,7 @@ class Period { Period({this.close, this.open}); - factory Period.fromJson(Map json) { - return Period( - close: json['close'] != null ? Close.fromJson(json['close']) : null, - open: json['open'] != null ? Open.fromJson(json['open']) : null, - ); - } + factory Period.fromJson(Map json) => _$PeriodFromJson(json); + + Map toJson() => _$PeriodToJson(this); } diff --git a/lib/src/models/period.g.dart b/lib/src/models/period.g.dart new file mode 100644 index 0000000..b52c3b0 --- /dev/null +++ b/lib/src/models/period.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'period.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Period _$PeriodFromJson(Map json) => Period( + close: json['close'] == null + ? null + : Close.fromJson(Map.from(json['close'] as Map)), + open: json['open'] == null + ? null + : Open.fromJson(Map.from(json['open'] as Map)), + ); + +Map _$PeriodToJson(Period instance) => { + 'close': instance.close?.toJson(), + 'open': instance.open?.toJson(), + }; diff --git a/lib/src/models/photo.dart b/lib/src/models/photo.dart index 23a1e58..a631c1e 100644 --- a/lib/src/models/photo.dart +++ b/lib/src/models/photo.dart @@ -1,5 +1,11 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'photo.g.dart'; + +@JsonSerializable() class Photo { /// [photoReference] a string used to identify the photo when you perform a Photo request. + @JsonKey(name: "photo_reference") final String? photoReference; /// [height] the maximum height of the image. @@ -9,18 +15,12 @@ class Photo { final int? width; /// [htmlAttributions] contains any required attributions. This field will always be present, but may be empty. + @JsonKey(name: "html_attributions") final List? htmlAttributions; Photo({this.photoReference, this.height, this.width, this.htmlAttributions}); - factory Photo.fromJson(Map json) { - return Photo( - photoReference: json['photo_reference'], - height: json['height'], - width: json['width'], - htmlAttributions: json['html_attributions'] != null - ? (json['html_attributions'] as List).cast() - : null, - ); - } + factory Photo.fromJson(Map json) => _$PhotoFromJson(json); + + Map toJson() => _$PhotoToJson(this); } diff --git a/lib/src/models/photo.g.dart b/lib/src/models/photo.g.dart new file mode 100644 index 0000000..a7d1e42 --- /dev/null +++ b/lib/src/models/photo.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'photo.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Photo _$PhotoFromJson(Map json) => Photo( + photoReference: json['photo_reference'] as String?, + height: json['height'] as int?, + width: json['width'] as int?, + htmlAttributions: (json['html_attributions'] as List?) + ?.map((e) => e as String) + .toList(), + ); + +Map _$PhotoToJson(Photo instance) => { + 'photo_reference': instance.photoReference, + 'height': instance.height, + 'width': instance.width, + 'html_attributions': instance.htmlAttributions, + }; diff --git a/lib/src/models/plus_code.dart b/lib/src/models/plus_code.dart index 852cd5b..fcd1353 100644 --- a/lib/src/models/plus_code.dart +++ b/lib/src/models/plus_code.dart @@ -1,16 +1,21 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'plus_code.g.dart'; + +@JsonSerializable() class PlusCode { /// [globalCode] is a 4 character area code and 6 character or longer local code (849VCWC8+R9). + @JsonKey(name: "global_code") final String? globalCode; /// [compoundCode] is a 6 character or longer local code with an explicit location (CWC8+R9, Mountain View, CA, USA). + @JsonKey(name: "compound_code") final String? compoundCode; PlusCode({this.globalCode, this.compoundCode}); - factory PlusCode.fromJson(Map json) { - return PlusCode( - globalCode: json['global_code'], - compoundCode: json['compound_code'], - ); - } + factory PlusCode.fromJson(Map json) => + _$PlusCodeFromJson(json); + + Map toJson() => _$PlusCodeToJson(this); } diff --git a/lib/src/models/plus_code.g.dart b/lib/src/models/plus_code.g.dart new file mode 100644 index 0000000..6389562 --- /dev/null +++ b/lib/src/models/plus_code.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'plus_code.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +PlusCode _$PlusCodeFromJson(Map json) => PlusCode( + globalCode: json['global_code'] as String?, + compoundCode: json['compound_code'] as String?, + ); + +Map _$PlusCodeToJson(PlusCode instance) => { + 'global_code': instance.globalCode, + 'compound_code': instance.compoundCode, + }; diff --git a/lib/src/models/review.dart b/lib/src/models/review.dart index 224cb27..45289c7 100644 --- a/lib/src/models/review.dart +++ b/lib/src/models/review.dart @@ -1,8 +1,15 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'review.g.dart'; + +@JsonSerializable() class Review { /// [authorName] the name of the user who submitted the review. Anonymous reviews are attributed to "A Google user". + @JsonKey(name: "author_name") final String? authorName; /// [authorUrl] the URL to the user's Google Maps Local Guides profile, if available. + @JsonKey(name: "author_url") final String? authorUrl; /// [language] an IETF language code indicating the language used in the user's review. @@ -11,12 +18,14 @@ class Review { final String? language; /// [profilePhotoUrl] the URL to the user's profile photo, if available. + @JsonKey(name: "profile_photo_url") final String? profilePhotoUrl; /// [rating] the user's overall rating for this place. This is a whole number, ranging from 1 to 5. final int? rating; /// [relativeTimeDescription] the time that the review was submitted, relative to the current time. + @JsonKey(name: "relative_time_description") final String? relativeTimeDescription; /// [text] the user's review. When reviewing a location with Google Places, text reviews are considered optional. @@ -38,16 +47,7 @@ class Review { this.time, }); - factory Review.fromJson(Map json) { - return Review( - authorName: json['author_name'], - authorUrl: json['author_url'], - language: json['language'], - profilePhotoUrl: json['profile_photo_url'], - rating: json['rating'], - relativeTimeDescription: json['relative_time_description'], - text: json['text'], - time: json['time'], - ); - } + factory Review.fromJson(Map json) => _$ReviewFromJson(json); + + Map toJson() => _$ReviewToJson(this); } diff --git a/lib/src/models/review.g.dart b/lib/src/models/review.g.dart new file mode 100644 index 0000000..757a777 --- /dev/null +++ b/lib/src/models/review.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'review.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Review _$ReviewFromJson(Map json) => Review( + authorName: json['author_name'] as String?, + authorUrl: json['author_url'] as String?, + language: json['language'] as String?, + profilePhotoUrl: json['profile_photo_url'] as String?, + rating: json['rating'] as int?, + relativeTimeDescription: json['relative_time_description'] as String?, + text: json['text'] as String?, + time: json['time'] as int?, + ); + +Map _$ReviewToJson(Review instance) => { + 'author_name': instance.authorName, + 'author_url': instance.authorUrl, + 'language': instance.language, + 'profile_photo_url': instance.profilePhotoUrl, + 'rating': instance.rating, + 'relative_time_description': instance.relativeTimeDescription, + 'text': instance.text, + 'time': instance.time, + }; diff --git a/lib/src/models/southwest.dart b/lib/src/models/southwest.dart index 36b08c3..5ed8261 100644 --- a/lib/src/models/southwest.dart +++ b/lib/src/models/southwest.dart @@ -1,13 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'southwest.g.dart'; + +@JsonSerializable() class Southwest { final double? lat; final double? lng; Southwest({this.lat, this.lng}); - factory Southwest.fromJson(Map json) { - return Southwest( - lat: json['lat'] != null ? json['lat'].toDouble() : null, - lng: json['lng'] != null ? json['lng'].toDouble() : null, - ); - } + factory Southwest.fromJson(Map json) => + _$SouthwestFromJson(json); + + Map toJson() => _$SouthwestToJson(this); } diff --git a/lib/src/models/southwest.g.dart b/lib/src/models/southwest.g.dart new file mode 100644 index 0000000..038c9f3 --- /dev/null +++ b/lib/src/models/southwest.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'southwest.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Southwest _$SouthwestFromJson(Map json) => Southwest( + lat: (json['lat'] as num?)?.toDouble(), + lng: (json['lng'] as num?)?.toDouble(), + ); + +Map _$SouthwestToJson(Southwest instance) => { + 'lat': instance.lat, + 'lng': instance.lng, + }; diff --git a/lib/src/models/structured_formatting.dart b/lib/src/models/structured_formatting.dart index e4e00db..c9baf0a 100644 --- a/lib/src/models/structured_formatting.dart +++ b/lib/src/models/structured_formatting.dart @@ -1,28 +1,30 @@ import 'package:google_place/src/models/main_text_matched_substring.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'structured_formatting.g.dart'; + +@JsonSerializable() class StructuredFormatting { /// [mainText] contains the main text of a prediction, usually the name of the place. + @JsonKey(name: "main_text") final String? mainText; /// [mainTextMatchedSubstrings] contains an array with offset value and length. /// These describe the location of the entered term in the prediction result text, /// so that the term can be highlighted if desired. + @JsonKey(name: "main_text_matched_substrings") final List? mainTextMatchedSubstrings; /// [secondaryText] contains the secondary text of a prediction, usually the location of the place. + @JsonKey(name: "secondary_text") final String? secondaryText; StructuredFormatting( {this.mainText, this.mainTextMatchedSubstrings, this.secondaryText}); - factory StructuredFormatting.fromJson(Map json) { - return StructuredFormatting( - mainText: json['main_text'] as String?, - mainTextMatchedSubstrings: json['main_text_matched_substrings'] - .map( - (json) => MainTextMatchedSubstring.fromJson(json)) - .toList(), - secondaryText: json['secondary_text'] as String?, - ); - } + factory StructuredFormatting.fromJson(Map json) => + _$StructuredFormattingFromJson(json); + + Map toJson() => _$StructuredFormattingToJson(this); } diff --git a/lib/src/models/structured_formatting.g.dart b/lib/src/models/structured_formatting.g.dart new file mode 100644 index 0000000..cfdc7c1 --- /dev/null +++ b/lib/src/models/structured_formatting.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'structured_formatting.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +StructuredFormatting _$StructuredFormattingFromJson(Map json) => + StructuredFormatting( + mainText: json['main_text'] as String?, + mainTextMatchedSubstrings: + (json['main_text_matched_substrings'] as List?) + ?.map((e) => MainTextMatchedSubstring.fromJson( + Map.from(e as Map))) + .toList(), + secondaryText: json['secondary_text'] as String?, + ); + +Map _$StructuredFormattingToJson( + StructuredFormatting instance) => + { + 'main_text': instance.mainText, + 'main_text_matched_substrings': + instance.mainTextMatchedSubstrings?.map((e) => e.toJson()).toList(), + 'secondary_text': instance.secondaryText, + }; diff --git a/lib/src/models/term.dart b/lib/src/models/term.dart index 93d8b2a..3f315b9 100644 --- a/lib/src/models/term.dart +++ b/lib/src/models/term.dart @@ -1,3 +1,8 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'term.g.dart'; + +@JsonSerializable() class Term { /// [offset] defining the start position of this term in the description final int? offset; @@ -7,10 +12,7 @@ class Term { Term({this.offset, this.value}); - factory Term.fromJson(Map json) { - return Term( - offset: json['offset'] as int?, - value: json['value'] as String?, - ); - } + factory Term.fromJson(Map json) => _$TermFromJson(json); + + Map toJson() => _$TermToJson(this); } diff --git a/lib/src/models/term.g.dart b/lib/src/models/term.g.dart new file mode 100644 index 0000000..68a359c --- /dev/null +++ b/lib/src/models/term.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'term.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Term _$TermFromJson(Map json) => Term( + offset: json['offset'] as int?, + value: json['value'] as String?, + ); + +Map _$TermToJson(Term instance) => { + 'offset': instance.offset, + 'value': instance.value, + }; diff --git a/lib/src/models/viewport.dart b/lib/src/models/viewport.dart index 41650d5..a81764c 100644 --- a/lib/src/models/viewport.dart +++ b/lib/src/models/viewport.dart @@ -1,20 +1,18 @@ import 'package:google_place/src/models/northeast.dart'; import 'package:google_place/src/models/southwest.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'viewport.g.dart'; + +@JsonSerializable() class Viewport { final Northeast? northeast; final Southwest? southwest; Viewport({this.northeast, this.southwest}); - factory Viewport.fromJson(Map json) { - return Viewport( - northeast: json['northeast'] != null - ? Northeast.fromJson(json['northeast']) - : null, - southwest: json['southwest'] != null - ? Southwest.fromJson(json['southwest']) - : null, - ); - } + factory Viewport.fromJson(Map json) => + _$ViewportFromJson(json); + + Map toJson() => _$ViewportToJson(this); } diff --git a/lib/src/models/viewport.g.dart b/lib/src/models/viewport.g.dart new file mode 100644 index 0000000..039db9b --- /dev/null +++ b/lib/src/models/viewport.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'viewport.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Viewport _$ViewportFromJson(Map json) => Viewport( + northeast: json['northeast'] == null + ? null + : Northeast.fromJson( + Map.from(json['northeast'] as Map)), + southwest: json['southwest'] == null + ? null + : Southwest.fromJson( + Map.from(json['southwest'] as Map)), + ); + +Map _$ViewportToJson(Viewport instance) => { + 'northeast': instance.northeast?.toJson(), + 'southwest': instance.southwest?.toJson(), + }; diff --git a/lib/src/photos/photos.dart b/lib/src/photos/photos.dart index 4e61b53..4663499 100644 --- a/lib/src/photos/photos.dart +++ b/lib/src/photos/photos.dart @@ -97,10 +97,15 @@ class Photos { int? maxWidth, ) { Map queryParameters = { - 'photoreference': photoReference, + 'photo_reference': photoReference, 'key': apiKEY, }; - if (maxHeight != null) {} + if (maxHeight != null) { + var item = { + 'maxheight': maxHeight.toString(), + }; + queryParameters.addAll(item); + } if (maxWidth != null) { var item = { 'maxwidth': maxWidth.toString(), diff --git a/lib/src/search/find_place_response.dart b/lib/src/search/find_place_response.dart index 675d5e1..868d873 100644 --- a/lib/src/search/find_place_response.dart +++ b/lib/src/search/find_place_response.dart @@ -2,12 +2,20 @@ import 'dart:convert'; import 'package:google_place/src/models/debug_log.dart'; import 'package:google_place/src/search/search_candidate.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'find_place_response.g.dart'; /// The Find Place Search response contains html Attributions and search results and status + +@JsonSerializable() class FindPlaceResponse { final String? status; + @JsonKey(name: "html_attributions") final List? htmlAttributions; + @JsonKey(name: "next_page_token") final String? nextPageToken; + @JsonKey(name: "debug_log") final DebugLog? debugLog; final List? candidates; @@ -19,23 +27,10 @@ class FindPlaceResponse { this.candidates, }); - factory FindPlaceResponse.fromJson(Map json) { - return FindPlaceResponse( - status: json['status'], - htmlAttributions: json['html_attributions'] != null - ? (json['html_attributions'] as List).cast() - : null, - nextPageToken: json['next_page_token'], - debugLog: json['debug_log'] != null - ? DebugLog.fromJson(json['debug_log']) - : null, - candidates: json['candidates'] != null - ? json['candidates'] - .map((json) => SearchCandidate.fromJson(json)) - .toList() - : null, - ); - } + factory FindPlaceResponse.fromJson(Map json) => + _$FindPlaceResponseFromJson(json); + + Map toJson() => _$FindPlaceResponseToJson(this); static FindPlaceResponse parseFindPlaceResult(String responseBody) { final parsed = json.decode(responseBody).cast(); diff --git a/lib/src/search/find_place_response.g.dart b/lib/src/search/find_place_response.g.dart new file mode 100644 index 0000000..2f05869 --- /dev/null +++ b/lib/src/search/find_place_response.g.dart @@ -0,0 +1,32 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'find_place_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +FindPlaceResponse _$FindPlaceResponseFromJson(Map json) => FindPlaceResponse( + status: json['status'] as String?, + htmlAttributions: (json['html_attributions'] as List?) + ?.map((e) => e as String) + .toList(), + nextPageToken: json['next_page_token'] as String?, + debugLog: json['debug_log'] == null + ? null + : DebugLog.fromJson( + Map.from(json['debug_log'] as Map)), + candidates: (json['candidates'] as List?) + ?.map((e) => + SearchCandidate.fromJson(Map.from(e as Map))) + .toList(), + ); + +Map _$FindPlaceResponseToJson(FindPlaceResponse instance) => + { + 'status': instance.status, + 'html_attributions': instance.htmlAttributions, + 'next_page_token': instance.nextPageToken, + 'debug_log': instance.debugLog?.toJson(), + 'candidates': instance.candidates?.map((e) => e.toJson()).toList(), + }; diff --git a/lib/src/search/near_by_search_response.dart b/lib/src/search/near_by_search_response.dart index 068d636..9e711ee 100644 --- a/lib/src/search/near_by_search_response.dart +++ b/lib/src/search/near_by_search_response.dart @@ -2,12 +2,19 @@ import 'dart:convert'; import 'package:google_place/src/models/debug_log.dart'; import 'package:google_place/src/search/search_result.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'near_by_search_response.g.dart'; /// The Near By Search response contains html Attributions and search results and status +@JsonSerializable() class NearBySearchResponse { final String? status; + @JsonKey(name: "html_attributions") final List? htmlAttributions; + @JsonKey(name: "next_page_token") final String? nextPageToken; + @JsonKey(name: "debug_log") final DebugLog? debugLog; final List? results; @@ -19,23 +26,10 @@ class NearBySearchResponse { this.results, }); - factory NearBySearchResponse.fromJson(Map json) { - return NearBySearchResponse( - status: json['status'], - htmlAttributions: json['html_attributions'] != null - ? (json['html_attributions'] as List).cast() - : null, - nextPageToken: json['next_page_token'], - debugLog: json['debug_log'] != null - ? DebugLog.fromJson(json['debug_log']) - : null, - results: json['results'] != null - ? json['results'] - .map((json) => SearchResult.fromJson(json)) - .toList() - : null, - ); - } + factory NearBySearchResponse.fromJson(Map json) => + _$NearBySearchResponseFromJson(json); + + Map toJson() => _$NearBySearchResponseToJson(this); static NearBySearchResponse parseNearBySearchResult(String responseBody) { final parsed = json.decode(responseBody).cast(); diff --git a/lib/src/search/near_by_search_response.g.dart b/lib/src/search/near_by_search_response.g.dart new file mode 100644 index 0000000..8b3c056 --- /dev/null +++ b/lib/src/search/near_by_search_response.g.dart @@ -0,0 +1,34 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'near_by_search_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NearBySearchResponse _$NearBySearchResponseFromJson(Map json) => + NearBySearchResponse( + status: json['status'] as String?, + htmlAttributions: (json['html_attributions'] as List?) + ?.map((e) => e as String) + .toList(), + nextPageToken: json['next_page_token'] as String?, + debugLog: json['debug_log'] == null + ? null + : DebugLog.fromJson( + Map.from(json['debug_log'] as Map)), + results: (json['results'] as List?) + ?.map( + (e) => SearchResult.fromJson(Map.from(e as Map))) + .toList(), + ); + +Map _$NearBySearchResponseToJson( + NearBySearchResponse instance) => + { + 'status': instance.status, + 'html_attributions': instance.htmlAttributions, + 'next_page_token': instance.nextPageToken, + 'debug_log': instance.debugLog?.toJson(), + 'results': instance.results?.map((e) => e.toJson()).toList(), + }; diff --git a/lib/src/search/search_candidate.dart b/lib/src/search/search_candidate.dart index 8e77089..ae522f3 100644 --- a/lib/src/search/search_candidate.dart +++ b/lib/src/search/search_candidate.dart @@ -2,7 +2,11 @@ import 'package:google_place/src/models/geometry.dart'; import 'package:google_place/src/models/opening_hours.dart'; import 'package:google_place/src/models/photo.dart'; import 'package:google_place/src/models/plus_code.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'search_candidate.g.dart'; + +@JsonSerializable() class SearchCandidate { /// [geometry] contains geometry information about the result, /// generally including the location (geocode) of the place and (optionally) @@ -14,9 +18,11 @@ class SearchCandidate { /// OPERATIONAL /// CLOSED_TEMPORARILY /// CLOSED_PERMANENTLY + @JsonKey(name: "business_status") final String? businessStatus; /// [openingHours] show opening hours + @JsonKey(name: "opening_hours") final OpeningHours? openingHours; /// [photos] an array of photo objects, each containing a reference to an image. @@ -26,10 +32,12 @@ class SearchCandidate { /// that represents an area: 1/8000th of a degree by 1/8000th of a degree (about 14m x 14m at the equator) or smaller. /// Plus codes can be used as a replacement for street addresses in places where they do not exist /// (where buildings are not numbered or streets are not named). + @JsonKey(name: "plus_code") final PlusCode? plusCode; /// [formattedAddress] is a string containing the human-readable address of this place. /// Often this address is equivalent to the "postal address". + @JsonKey(name: "formatted_address") final String? formattedAddress; /// [name] contains the human-readable name for the returned result. @@ -47,6 +55,7 @@ class SearchCandidate { /// [placeId] a textual identifier that uniquely identifies a place. To retrieve information about the place, /// pass this identifier in the placeId field of a Places API request. For more information about place IDs. + @JsonKey(name: "place_id") final String? placeId; /// [priceLevel] The price level of the place, on a scale of 0 to 4. @@ -56,6 +65,7 @@ class SearchCandidate { /// 2 — Moderate /// 3 — Expensive /// 4 — Very Expensive + @JsonKey(name: "price_level") final int? priceLevel; /// [reference] contains reference. @@ -69,6 +79,7 @@ class SearchCandidate { final List? types; /// [userRatingsTotal] is user ratings total. + @JsonKey(name: "user_ratings_total") final int? userRatingsTotal; /// [vicinity] contains a feature name of a nearby location. Often this feature refers to a street or @@ -79,6 +90,7 @@ class SearchCandidate { /// or temporarily (value true). If the place is operational, or if no data is available, the flag is absent from the response. @Deprecated( 'permanently_closed is now deprecated. Instead, use business_status to get the operational status of businesses.') + @JsonKey(name: "permanently_closed") final bool? permanentlyClosed; SearchCandidate({ @@ -102,35 +114,8 @@ class SearchCandidate { this.permanentlyClosed, }); - factory SearchCandidate.fromJson(Map json) { - return SearchCandidate( - geometry: - json['geometry'] != null ? Geometry.fromJson(json['geometry']) : null, - businessStatus: json['business_status'], - openingHours: json['opening_hours'] != null - ? OpeningHours.fromJson(json['opening_hours']) - : null, - photos: json['photos'] != null - ? json['photos'].map((json) => Photo.fromJson(json)).toList() - : null, - plusCode: json['plus_code'] != null - ? PlusCode.fromJson(json['plus_code']) - : null, - formattedAddress: json['formatted_address'], - name: json['name'], - rating: json['rating'] != null ? json['rating'].toDouble() : null, - icon: json['icon'], - id: json['id'], - placeId: json['place_id'], - priceLevel: json['price_level'], - reference: json['reference'], - scope: json['scope'], - types: json['types'] != null - ? (json['types'] as List).cast() - : null, - userRatingsTotal: json['user_ratings_total'], - vicinity: json['vicinity'], - permanentlyClosed: json['permanently_closed'], - ); - } + factory SearchCandidate.fromJson(Map json) => + _$SearchCandidateFromJson(json); + + Map toJson() => _$SearchCandidateToJson(this); } diff --git a/lib/src/search/search_candidate.g.dart b/lib/src/search/search_candidate.g.dart new file mode 100644 index 0000000..6e0ee17 --- /dev/null +++ b/lib/src/search/search_candidate.g.dart @@ -0,0 +1,62 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'search_candidate.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SearchCandidate _$SearchCandidateFromJson(Map json) => SearchCandidate( + geometry: json['geometry'] == null + ? null + : Geometry.fromJson( + Map.from(json['geometry'] as Map)), + businessStatus: json['business_status'] as String?, + openingHours: json['opening_hours'] == null + ? null + : OpeningHours.fromJson( + Map.from(json['opening_hours'] as Map)), + photos: (json['photos'] as List?) + ?.map((e) => Photo.fromJson(Map.from(e as Map))) + .toList(), + plusCode: json['plus_code'] == null + ? null + : PlusCode.fromJson( + Map.from(json['plus_code'] as Map)), + formattedAddress: json['formatted_address'] as String?, + name: json['name'] as String?, + rating: (json['rating'] as num?)?.toDouble(), + icon: json['icon'] as String?, + id: json['id'] as String?, + placeId: json['place_id'] as String?, + priceLevel: json['price_level'] as int?, + reference: json['reference'] as String?, + scope: json['scope'] as String?, + types: + (json['types'] as List?)?.map((e) => e as String).toList(), + userRatingsTotal: json['user_ratings_total'] as int?, + vicinity: json['vicinity'] as String?, + permanentlyClosed: json['permanently_closed'] as bool?, + ); + +Map _$SearchCandidateToJson(SearchCandidate instance) => + { + 'geometry': instance.geometry?.toJson(), + 'business_status': instance.businessStatus, + 'opening_hours': instance.openingHours?.toJson(), + 'photos': instance.photos?.map((e) => e.toJson()).toList(), + 'plus_code': instance.plusCode?.toJson(), + 'formatted_address': instance.formattedAddress, + 'name': instance.name, + 'rating': instance.rating, + 'icon': instance.icon, + 'id': instance.id, + 'place_id': instance.placeId, + 'price_level': instance.priceLevel, + 'reference': instance.reference, + 'scope': instance.scope, + 'types': instance.types, + 'user_ratings_total': instance.userRatingsTotal, + 'vicinity': instance.vicinity, + 'permanently_closed': instance.permanentlyClosed, + }; diff --git a/lib/src/search/search_result.dart b/lib/src/search/search_result.dart index 125ac62..eaa6a6d 100644 --- a/lib/src/search/search_result.dart +++ b/lib/src/search/search_result.dart @@ -2,7 +2,11 @@ import 'package:google_place/src/models/geometry.dart'; import 'package:google_place/src/models/opening_hours.dart'; import 'package:google_place/src/models/photo.dart'; import 'package:google_place/src/models/plus_code.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'search_result.g.dart'; + +@JsonSerializable() class SearchResult { /// [geometry] contains geometry information about the result, /// generally including the location (geocode) of the place and (optionally) @@ -14,9 +18,11 @@ class SearchResult { /// OPERATIONAL /// CLOSED_TEMPORARILY /// CLOSED_PERMANENTLY + @JsonKey(name: "business_status") final String? businessStatus; /// [openingHours] show opening hours + @JsonKey(name: "opening_hours") final OpeningHours? openingHours; /// [photos] an array of photo objects, each containing a reference to an image. @@ -26,10 +32,12 @@ class SearchResult { /// that represents an area: 1/8000th of a degree by 1/8000th of a degree (about 14m x 14m at the equator) or smaller. /// Plus codes can be used as a replacement for street addresses in places where they do not exist /// (where buildings are not numbered or streets are not named). + @JsonKey(name: "plus_code") final PlusCode? plusCode; /// [formattedAddress] is a string containing the human-readable address of this place. /// Often this address is equivalent to the "postal address". + @JsonKey(name: "formatted_address") final String? formattedAddress; /// [name] contains the human-readable name for the returned result. @@ -47,6 +55,7 @@ class SearchResult { /// [placeId] a textual identifier that uniquely identifies a place. To retrieve information about the place, /// pass this identifier in the placeId field of a Places API request. For more information about place IDs. + @JsonKey(name: "place_id") final String? placeId; /// [priceLevel] The price level of the place, on a scale of 0 to 4. @@ -56,6 +65,7 @@ class SearchResult { /// 2 — Moderate /// 3 — Expensive /// 4 — Very Expensive + @JsonKey(name: "price_level") final int? priceLevel; /// [reference] contains reference. @@ -69,6 +79,7 @@ class SearchResult { final List? types; /// [userRatingsTotal] is user ratings total. + @JsonKey(name: "user_ratings_total") final int? userRatingsTotal; /// [vicinity] contains a feature name of a nearby location. Often this feature refers to a street or @@ -79,6 +90,7 @@ class SearchResult { /// or temporarily (value true). If the place is operational, or if no data is available, the flag is absent from the response. @Deprecated( 'permanently_closed is now deprecated. Instead, use business_status to get the operational status of businesses.') + @JsonKey(name: "permanently_closed") final bool? permanentlyClosed; SearchResult({ @@ -102,35 +114,8 @@ class SearchResult { this.permanentlyClosed, }); - factory SearchResult.fromJson(Map json) { - return SearchResult( - geometry: - json['geometry'] != null ? Geometry.fromJson(json['geometry']) : null, - businessStatus: json['business_status'], - openingHours: json['opening_hours'] != null - ? OpeningHours.fromJson(json['opening_hours']) - : null, - photos: json['photos'] != null - ? json['photos'].map((json) => Photo.fromJson(json)).toList() - : null, - plusCode: json['plus_code'] != null - ? PlusCode.fromJson(json['plus_code']) - : null, - formattedAddress: json['formatted_address'], - name: json['name'], - rating: json['rating'] != null ? json['rating'].toDouble() : null, - icon: json['icon'], - id: json['id'], - placeId: json['place_id'], - priceLevel: json['price_level'], - reference: json['reference'], - scope: json['scope'], - types: json['types'] != null - ? (json['types'] as List).cast() - : null, - userRatingsTotal: json['user_ratings_total'], - vicinity: json['vicinity'], - permanentlyClosed: json['permanently_closed'], - ); - } + factory SearchResult.fromJson(Map json) => + _$SearchResultFromJson(json); + + Map toJson() => _$SearchResultToJson(this); } diff --git a/lib/src/search/search_result.g.dart b/lib/src/search/search_result.g.dart new file mode 100644 index 0000000..14d8cd7 --- /dev/null +++ b/lib/src/search/search_result.g.dart @@ -0,0 +1,62 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'search_result.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SearchResult _$SearchResultFromJson(Map json) => SearchResult( + geometry: json['geometry'] == null + ? null + : Geometry.fromJson( + Map.from(json['geometry'] as Map)), + businessStatus: json['business_status'] as String?, + openingHours: json['opening_hours'] == null + ? null + : OpeningHours.fromJson( + Map.from(json['opening_hours'] as Map)), + photos: (json['photos'] as List?) + ?.map((e) => Photo.fromJson(Map.from(e as Map))) + .toList(), + plusCode: json['plus_code'] == null + ? null + : PlusCode.fromJson( + Map.from(json['plus_code'] as Map)), + formattedAddress: json['formatted_address'] as String?, + name: json['name'] as String?, + rating: (json['rating'] as num?)?.toDouble(), + icon: json['icon'] as String?, + id: json['id'] as String?, + placeId: json['place_id'] as String?, + priceLevel: json['price_level'] as int?, + reference: json['reference'] as String?, + scope: json['scope'] as String?, + types: + (json['types'] as List?)?.map((e) => e as String).toList(), + userRatingsTotal: json['user_ratings_total'] as int?, + vicinity: json['vicinity'] as String?, + permanentlyClosed: json['permanently_closed'] as bool?, + ); + +Map _$SearchResultToJson(SearchResult instance) => + { + 'geometry': instance.geometry?.toJson(), + 'business_status': instance.businessStatus, + 'opening_hours': instance.openingHours?.toJson(), + 'photos': instance.photos?.map((e) => e.toJson()).toList(), + 'plus_code': instance.plusCode?.toJson(), + 'formatted_address': instance.formattedAddress, + 'name': instance.name, + 'rating': instance.rating, + 'icon': instance.icon, + 'id': instance.id, + 'place_id': instance.placeId, + 'price_level': instance.priceLevel, + 'reference': instance.reference, + 'scope': instance.scope, + 'types': instance.types, + 'user_ratings_total': instance.userRatingsTotal, + 'vicinity': instance.vicinity, + 'permanently_closed': instance.permanentlyClosed, + }; diff --git a/lib/src/search/text_search_response.dart b/lib/src/search/text_search_response.dart index 52d44d5..c4e1a3e 100644 --- a/lib/src/search/text_search_response.dart +++ b/lib/src/search/text_search_response.dart @@ -2,12 +2,19 @@ import 'dart:convert'; import 'package:google_place/src/models/debug_log.dart'; import 'package:google_place/src/search/search_result.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'text_search_response.g.dart'; /// The Text Search response contains html Attributions and search results and status +@JsonSerializable() class TextSearchResponse { final String? status; + @JsonKey(name: "html_attributions") final List? htmlAttributions; + @JsonKey(name: "next_page_token") final String? nextPageToken; + @JsonKey(name: "debug_log") final DebugLog? debugLog; final List? results; @@ -19,23 +26,10 @@ class TextSearchResponse { this.results, }); - factory TextSearchResponse.fromJson(Map json) { - return TextSearchResponse( - status: json['status'], - htmlAttributions: json['html_attributions'] != null - ? (json['html_attributions'] as List).cast() - : null, - nextPageToken: json['next_page_token'], - debugLog: json['debug_log'] != null - ? DebugLog.fromJson(json['debug_log']) - : null, - results: json['results'] != null - ? json['results'] - .map((json) => SearchResult.fromJson(json)) - .toList() - : null, - ); - } + factory TextSearchResponse.fromJson(Map json) => + _$TextSearchResponseFromJson(json); + + Map toJson() => _$TextSearchResponseToJson(this); static TextSearchResponse parseTextSearchResult(String responseBody) { final parsed = json.decode(responseBody).cast(); diff --git a/lib/src/search/text_search_response.g.dart b/lib/src/search/text_search_response.g.dart new file mode 100644 index 0000000..6e1a930 --- /dev/null +++ b/lib/src/search/text_search_response.g.dart @@ -0,0 +1,32 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'text_search_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +TextSearchResponse _$TextSearchResponseFromJson(Map json) => TextSearchResponse( + status: json['status'] as String?, + htmlAttributions: (json['html_attributions'] as List?) + ?.map((e) => e as String) + .toList(), + nextPageToken: json['next_page_token'] as String?, + debugLog: json['debug_log'] == null + ? null + : DebugLog.fromJson( + Map.from(json['debug_log'] as Map)), + results: (json['results'] as List?) + ?.map( + (e) => SearchResult.fromJson(Map.from(e as Map))) + .toList(), + ); + +Map _$TextSearchResponseToJson(TextSearchResponse instance) => + { + 'status': instance.status, + 'html_attributions': instance.htmlAttributions, + 'next_page_token': instance.nextPageToken, + 'debug_log': instance.debugLog?.toJson(), + 'results': instance.results?.map((e) => e.toJson()).toList(), + }; diff --git a/pubspec.lock b/pubspec.lock index 31ab8d0..8bbd913 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,55 +1,206 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: d976d24314f193899a3079b14fe336215a63a3b1e1c3743eabba8f83e049e9a9 + url: "https://pub.dev" + source: hosted + version: "49.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "40ba2c6d2ab41a66476f8f1f099da6be0795c1b47221f5e2c5f8ad6048cdffae" + url: "https://pub.dev" + source: hosted + version: "5.1.0" + args: + dependency: transitive + description: + name: args + sha256: b003c3098049a51720352d219b0bb5f219b60fbfb68e7a4748139a06a5676515 + url: "https://pub.dev" + source: hosted + version: "2.3.1" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: "5b7355c14258f5e7df24bad1566f7b991de3e54aeacfb94e1a65e5233d9739c1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "6bc5544ea6ce4428266e7ea680e945c68806c4aae2da0eb5e9ccf38df8d6acbf" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "687cf90a3951affac1bd5f9ecb5e3e90b60487f3d9cdc359bb310f8876bb02a6" + url: "https://pub.dev" + source: hosted + version: "2.0.10" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "93f05c041932674be039b0a2323d6cf57e5f2bbf884a3c0382f9e53fc45ebace" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "409c20ff6b6a9c9f4152fc9fcbf16440fedf02fcacc0fb26ea3b8eab9a860a40" + url: "https://pub.dev" + source: hosted + version: "7.2.4" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: d7a9cd57c215bdf8d502772447aa6b52a8ab3f956d25d5fdea6ef1df2d2dad60 + url: "https://pub.dev" + source: hosted + version: "8.4.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.3.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: "8e36feea6de5ea69f2199f29cf42a450a855738c498b57c0b980e2d3cca9c362" + url: "https://pub.dev" source: hosted version: "1.2.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: dd007e4fb8270916820a0d66e24f619266b60773cddd082c6439341645af2659 + url: "https://pub.dev" + source: hosted + version: "2.0.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "02ce3596b459c666530f045ad6f96209474e8fee6e4855940a3cee65fb872ec5" + url: "https://pub.dev" + source: hosted + version: "4.3.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "3.0.2" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "7a03456c3490394c8e7665890333e91ae8a49be43542b616e414449ac358acd4" + url: "https://pub.dev" + source: hosted + version: "2.2.4" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "04be3e934c52e082558cc9ee21f42f5c1cd7a1262f4c63cd0357c08d5bba81ec" + url: "https://pub.dev" + source: hosted + version: "1.0.1" flutter: dependency: transitive description: flutter @@ -60,108 +211,347 @@ packages: description: flutter source: sdk version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "4f4a162323c86ffc1245765cfe138872b8f069deb42f7dbb36115fa27f31469b" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + glob: + dependency: transitive + description: + name: glob + sha256: c51b4fdfee4d281f49b8c957f1add91b815473597f76bcf07377987f66a55729 + url: "https://pub.dev" + source: hosted + version: "2.1.0" + graphs: + dependency: transitive + description: + name: graphs + sha256: ae0b3d956ff324c6f8671f08dcb2dbd71c99cdbf2aa3ca63a14190c47aa6679c + url: "https://pub.dev" + source: hosted + version: "2.1.0" http: dependency: "direct main" description: name: http - url: "https://pub.dartlang.org" + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + url: "https://pub.dev" source: hosted - version: "0.13.3" + version: "1.2.1" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 + url: "https://pub.dev" source: hosted version: "4.0.0" + io: + dependency: transitive + description: + name: io + sha256: "0d4c73c3653ab85bf696d51a9657604c900a370549196a91f33e4c39af760852" + url: "https://pub.dev" + source: hosted + version: "1.0.3" + js: + dependency: transitive + description: + name: js + sha256: a5e201311cb08bf3912ebbe9a2be096e182d703f881136ec1e81a2338a9e120d + url: "https://pub.dev" + source: hosted + version: "0.6.4" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + sha256: "3520fa844009431b5d4491a5a778603520cdc399ab3406332dcc50f93547258c" + url: "https://pub.dev" + source: hosted + version: "4.7.0" + json_serializable: + dependency: "direct main" + description: + name: json_serializable + sha256: f8aec50d60afa63e7bd16b2f4eb95974bc99832a6ce5b632f6b5156b76c97f74 + url: "https://pub.dev" + source: hosted + version: "6.5.2" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: c0bbfe94d46aedf9b8b3e695cf3bd48c8e14b35e3b2c639e0aa7755d589ba946 + url: "https://pub.dev" + source: hosted + version: "1.1.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" + source: hosted + version: "0.8.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.12.0" + mime: + dependency: transitive + description: + name: mime + sha256: dab22e92b41aa1255ea90ddc4bc2feaf35544fd0728e209638cad041a6e3928a + url: "https://pub.dev" + source: hosted + version: "1.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.0" - pedantic: + version: "1.9.0" + pool: dependency: transitive description: - name: pedantic - url: "https://pub.dartlang.org" + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: b959af0a045c3484c4a8f4997731f5bfe4cac60d732fd8ce35b351f2d6a459fe + url: "https://pub.dev" + source: hosted + version: "2.1.2" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + shelf: + dependency: transitive + description: + name: shelf + sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + url: "https://pub.dev" + source: hosted + version: "1.4.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "6db16374bc3497d21aa0eebe674d3db9fdf82082aac0f04dc7b44e4af5b08afc" + url: "https://pub.dev" + source: hosted + version: "1.0.2" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "2d79738b6bbf38a43920e2b8d189e9a3ce6cc201f4b8fc76be5e4fe377b1c38d" + url: "https://pub.dev" + source: hosted + version: "1.2.6" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "3b67aade1d52416149c633ba1bb36df44d97c6b51830c2198e934e3fca87ca1f" + url: "https://pub.dev" + source: hosted + version: "1.3.3" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: f1d172e22a5432c042b5adfa9aff621372e4292231d9d73ad00f486ad01c2395 + url: "https://pub.dev" + source: hosted + version: "2.0.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.7.0" + timing: + dependency: transitive + description: + name: timing + sha256: c386d07d7f5efc613479a7c4d9d64b03710b03cfaa7e8ad5f2bfb295a1f0dfad + url: "https://pub.dev" + source: hosted + version: "1.0.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + url: "https://pub.dev" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.dev" + source: hosted + version: "14.2.1" + watcher: + dependency: transitive + description: + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: "3a969ddcc204a3e34e863d204b29c0752716f78b6f9cc8235083208d268a4ccd" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" + source: hosted + version: "3.1.1" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/pubspec.yaml b/pubspec.yaml index c5808ca..18bc937 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,8 +7,11 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: - http: ^0.13.3 + http: ^1.2.1 + json_annotation: ^4.7.0 + json_serializable: ^6.5.2 dev_dependencies: + build_runner: ^2.3.0 flutter_test: sdk: flutter