From ef7fdd730a59cd00f93a0e37409000b579e92d2f Mon Sep 17 00:00:00 2001 From: Bhargav B L Date: Tue, 22 Jun 2021 10:39:43 +0530 Subject: [PATCH 1/7] null safety migra --- example/android/app/build.gradle | 2 +- example/lib/main.dart | 1 - example/pubspec.lock | 30 +++++++++++++++--------------- example/pubspec.yaml | 2 +- lib/src/map.dart | 8 ++++---- pubspec.lock | 26 +++++++++++++------------- pubspec.yaml | 12 ++++++------ 7 files changed, 40 insertions(+), 41 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 56abd65b..10906082 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -39,7 +39,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.humazed.google_map_location_picker_example" - minSdkVersion 16 + minSdkVersion 20 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/example/lib/main.dart b/example/lib/main.dart index 4b345412..1faff1a5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -3,7 +3,6 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:google_map_location_picker/generated/l10n.dart' as location_picker; import 'package:google_map_location_picker/google_map_location_picker.dart'; -import 'package:google_map_location_picker_example/keys.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'generated/i18n.dart'; diff --git a/example/pubspec.lock b/example/pubspec.lock index b1713335..9cc379c6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,14 +7,14 @@ packages: name: android_intent url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -56,7 +56,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.3" fake_async: dependency: transitive description: @@ -80,7 +80,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter @@ -97,35 +97,35 @@ packages: name: geolocator url: "https://pub.dartlang.org" source: hosted - version: "6.2.1" + version: "7.1.0" geolocator_platform_interface: dependency: transitive description: name: geolocator_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.9" + version: "2.1.1" geolocator_web: dependency: transitive description: name: geolocator_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.3" google_map_location_picker: dependency: "direct dev" description: path: ".." relative: true source: path - version: "4.1.6" + version: "4.1.7" google_maps_flutter: dependency: transitive description: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.6" google_maps_flutter_platform_interface: dependency: transitive description: @@ -139,7 +139,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.0" + version: "0.13.3" http_parser: dependency: transitive description: @@ -188,7 +188,7 @@ packages: name: package_info url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" path: dependency: transitive description: @@ -216,7 +216,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.0" provider: dependency: transitive description: @@ -235,7 +235,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -277,7 +277,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: @@ -293,5 +293,5 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0-259.9.beta <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=2.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 862594e4..996c53f7 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.3 dev_dependencies: flutter_test: diff --git a/lib/src/map.dart b/lib/src/map.dart index eca20b2c..d0a0d454 100644 --- a/lib/src/map.dart +++ b/lib/src/map.dart @@ -95,7 +95,7 @@ class MapPickerState extends State { Position currentPosition; try { currentPosition = - await getCurrentPosition(desiredAccuracy: widget.desiredAccuracy); + await Geolocator.getCurrentPosition(desiredAccuracy: widget.desiredAccuracy); d("position = $currentPosition"); setState(() => _currentPosition = currentPosition); @@ -324,7 +324,7 @@ class MapPickerState extends State { var dialogOpen; Future _checkGeolocationPermission() async { - final geolocationStatus = await checkPermission(); + final geolocationStatus = await Geolocator.checkPermission(); d("geolocationStatus = $geolocationStatus"); if (geolocationStatus == LocationPermission.denied && dialogOpen == null) { @@ -399,7 +399,7 @@ class MapPickerState extends State { child: Text(S.of(context)?.ok ?? 'Ok'), onPressed: () { Navigator.of(context, rootNavigator: true).pop(); - openAppSettings(); + Geolocator.openAppSettings(); dialogOpen = null; }, ), @@ -412,7 +412,7 @@ class MapPickerState extends State { // TODO: 9/12/2020 this is no longer needed, remove in the next release Future _checkGps() async { - if (!(await isLocationServiceEnabled())) { + if (!(await Geolocator.isLocationServiceEnabled())) { if (Theme.of(context).platform == TargetPlatform.android) { showDialog( context: context, diff --git a/pubspec.lock b/pubspec.lock index ae3630e2..7dc533fa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: android_intent url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -73,7 +73,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter @@ -90,28 +90,28 @@ packages: name: geolocator url: "https://pub.dartlang.org" source: hosted - version: "6.2.1" + version: "7.1.0" geolocator_platform_interface: dependency: transitive description: name: geolocator_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.9" + version: "2.1.1" geolocator_web: dependency: transitive description: name: geolocator_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.3" google_maps_flutter: dependency: "direct main" description: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.6" google_maps_flutter_platform_interface: dependency: transitive description: @@ -125,7 +125,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.0" + version: "0.13.3" http_parser: dependency: transitive description: @@ -174,7 +174,7 @@ packages: name: package_info url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" path: dependency: transitive description: @@ -202,7 +202,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.0.0" provider: dependency: "direct main" description: @@ -221,7 +221,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: "direct main" description: @@ -263,7 +263,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: @@ -279,5 +279,5 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0-259.9.beta <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index e281a9a7..1fe65d8f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/humazed/google_map_location_picker # flutter pub pub publish --dry-run environment: - sdk: ">=2.2.2 <3.0.0" + sdk: ">=2.2.0 <3.0.0" flutter: ">=2.0.0" dependencies: @@ -16,13 +16,13 @@ dependencies: sdk: flutter intl: ^0.17.0 - google_maps_flutter: ^2.0.1 - geolocator: ^6.1.14 - android_intent: ^2.0.0 + google_maps_flutter: ^2.0.6 + geolocator: ^7.1.0 + android_intent: ^2.0.2 provider: ^5.0.0 - http: ^0.13.0 + http: ^0.13.3 stack_trace: ^1.10.0 - package_info: ^2.0.0 + package_info: ^2.0.2 dev_dependencies: flutter_test: From 72b0d06a5df0868325f2406df6e4e0bbb153e1ed Mon Sep 17 00:00:00 2001 From: Bhargav B L Date: Tue, 22 Jun 2021 10:40:01 +0530 Subject: [PATCH 2/7] null safety migra --- example/ios/Flutter/flutter_export_environment.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 example/ios/Flutter/flutter_export_environment.sh diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 00000000..d04202e9 --- /dev/null +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/blb/Development/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/blb/Development/google_map_location_picker/example" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1.0.0" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=false" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.packages" From 3cb447c59aba1474b9435c1c8b83a277ba65170b Mon Sep 17 00:00:00 2001 From: Bhargav B L Date: Tue, 22 Jun 2021 11:04:46 +0530 Subject: [PATCH 3/7] null safety migration completed --- example/lib/main.dart | 2 +- lib/generated/intl/messages_all.dart | 4 +- lib/generated/intl/messages_ar.dart | 2 +- lib/generated/intl/messages_de.dart | 2 +- lib/generated/intl/messages_en.dart | 2 +- lib/generated/intl/messages_es.dart | 2 +- lib/generated/intl/messages_fr.dart | 2 +- lib/generated/intl/messages_it.dart | 2 +- lib/generated/intl/messages_pt.dart | 2 +- lib/generated/intl/messages_ru.dart | 2 +- lib/generated/intl/messages_sr.dart | 2 +- lib/generated/intl/messages_tr.dart | 2 +- lib/generated/l10n.dart | 4 +- lib/src/google_map_location_picker.dart | 110 +++++++++++------------ lib/src/map.dart | 86 +++++++++--------- lib/src/model/auto_comp_iete_item.dart | 8 +- lib/src/model/location_result.dart | 6 +- lib/src/model/nearby_place.dart | 6 +- lib/src/providers/location_provider.dart | 6 +- lib/src/rich_suggestion.dart | 10 +-- lib/src/search_input.dart | 12 +-- lib/src/utils/loading_builder.dart | 16 ++-- lib/src/utils/location_utils.dart | 6 +- pubspec.yaml | 2 +- 24 files changed, 149 insertions(+), 149 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 1faff1a5..67c1c7bf 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -51,7 +51,7 @@ class _MyAppState extends State { onPressed: () async { LocationResult result = await showLocationPicker( context, - apiKey, + "", initialCenter: LatLng(31.1975844, 29.9598339), // automaticallyAnimateToCurrentLocation: true, // mapStylePath: 'assets/mapStyle.json', diff --git a/lib/generated/intl/messages_all.dart b/lib/generated/intl/messages_all.dart index f633e6ff..b22af192 100644 --- a/lib/generated/intl/messages_all.dart +++ b/lib/generated/intl/messages_all.dart @@ -40,7 +40,7 @@ Map _deferredLibraries = { 'tr': () => new Future.value(null), }; -MessageLookupByLibrary _findExact(String localeName) { +MessageLookupByLibrary? _findExact(String localeName) { switch (localeName) { case 'ar': return messages_ar.messages; @@ -91,7 +91,7 @@ bool _messagesExistFor(String locale) { } } -MessageLookupByLibrary _findGeneratedMessagesFor(String locale) { +MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; diff --git a/lib/generated/intl/messages_ar.dart b/lib/generated/intl/messages_ar.dart index be032a5c..be4ccfb8 100644 --- a/lib/generated/intl/messages_ar.dart +++ b/lib/generated/intl/messages_ar.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'ar'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("تم رفض إذن الوصل الي الموقع الجغرافي"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("تم رفض إذن الوصل الي الموقع الجغرافي بشكل نهائي"), diff --git a/lib/generated/intl/messages_de.dart b/lib/generated/intl/messages_de.dart index 2b6ee3f8..b8df1d3f 100644 --- a/lib/generated/intl/messages_de.dart +++ b/lib/generated/intl/messages_de.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'de'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Zugriff auf Standort verweigert"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("Zugriff auf Standort permanent verweigert"), diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 5bd6290e..dba6fb53 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'en'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Access to location denied"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("Access to location permanently denied"), diff --git a/lib/generated/intl/messages_es.dart b/lib/generated/intl/messages_es.dart index 0a301e0c..858ed892 100644 --- a/lib/generated/intl/messages_es.dart +++ b/lib/generated/intl/messages_es.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'es'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Acceso a la ubicación denegado"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("Acceso a la ubicación denegado permanentemente"), diff --git a/lib/generated/intl/messages_fr.dart b/lib/generated/intl/messages_fr.dart index c3924468..fdd2d342 100644 --- a/lib/generated/intl/messages_fr.dart +++ b/lib/generated/intl/messages_fr.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'fr'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Accès à l\'emplacement refusé"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("Accès à l\'emplacement refusé définitivement"), diff --git a/lib/generated/intl/messages_it.dart b/lib/generated/intl/messages_it.dart index 969dbf5a..f22c4622 100644 --- a/lib/generated/intl/messages_it.dart +++ b/lib/generated/intl/messages_it.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'it'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Accesso alla posizione rifiutato"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("Accesso alla posizione rifiutato permanentemente"), diff --git a/lib/generated/intl/messages_pt.dart b/lib/generated/intl/messages_pt.dart index 869c0e3c..1b178bf0 100644 --- a/lib/generated/intl/messages_pt.dart +++ b/lib/generated/intl/messages_pt.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'pt'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Acesso ao local negado"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("Acesso ao local negado permanentemente"), diff --git a/lib/generated/intl/messages_ru.dart b/lib/generated/intl/messages_ru.dart index ad0dd019..a4e5c343 100644 --- a/lib/generated/intl/messages_ru.dart +++ b/lib/generated/intl/messages_ru.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'ru'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Доступ к местоположению запрещен"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("Доступ к местоположению запрещен навсегда"), diff --git a/lib/generated/intl/messages_sr.dart b/lib/generated/intl/messages_sr.dart index f7120d17..d2f40758 100644 --- a/lib/generated/intl/messages_sr.dart +++ b/lib/generated/intl/messages_sr.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'sr'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Onemogućen pristup lokaciji"), "allow_access_to_the_location_services" : MessageLookupByLibrary.simpleMessage("Omogućite pristup Vašoj lokaciji"), diff --git a/lib/generated/intl/messages_tr.dart b/lib/generated/intl/messages_tr.dart index 690a4d2a..87db67f6 100644 --- a/lib/generated/intl/messages_tr.dart +++ b/lib/generated/intl/messages_tr.dart @@ -19,7 +19,7 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'tr'; - final messages = _notInlinedMessages(_notInlinedMessages); + final Map messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) => { "access_to_location_denied" : MessageLookupByLibrary.simpleMessage("Konum erişimi reddedildi"), "access_to_location_permanently_denied" : MessageLookupByLibrary.simpleMessage("Konuma erişim kalıcı olarak reddedildi"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 5591ce10..3558b672 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -15,7 +15,7 @@ import 'intl/messages_all.dart'; class S { S(); - static S current; + static late S current; static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); @@ -31,7 +31,7 @@ class S { }); } - static S of(BuildContext context) { + static S? of(BuildContext context) { return Localizations.of(context, S); } diff --git a/lib/src/google_map_location_picker.dart b/lib/src/google_map_location_picker.dart index b06dfda0..30d1511d 100644 --- a/lib/src/google_map_location_picker.dart +++ b/lib/src/google_map_location_picker.dart @@ -22,7 +22,7 @@ import 'utils/location_utils.dart'; class LocationPicker extends StatefulWidget { LocationPicker( this.apiKey, { - Key key, + Key? key, this.initialCenter, this.initialZoom, this.requiredGPS, @@ -44,28 +44,28 @@ class LocationPicker extends StatefulWidget { final String apiKey; - final LatLng initialCenter; - final double initialZoom; - final List countries; + final LatLng? initialCenter; + final double? initialZoom; + final List? countries; - final bool requiredGPS; - final bool myLocationButtonEnabled; - final bool layersButtonEnabled; - final bool automaticallyAnimateToCurrentLocation; + final bool? requiredGPS; + final bool? myLocationButtonEnabled; + final bool? layersButtonEnabled; + final bool? automaticallyAnimateToCurrentLocation; - final String mapStylePath; + final String? mapStylePath; - final Color appBarColor; - final BoxDecoration searchBarBoxDecoration; - final String hintText; - final Widget resultCardConfirmIcon; - final Alignment resultCardAlignment; - final Decoration resultCardDecoration; - final EdgeInsets resultCardPadding; + final Color? appBarColor; + final BoxDecoration? searchBarBoxDecoration; + final String? hintText; + final Widget? resultCardConfirmIcon; + final Alignment? resultCardAlignment; + final Decoration? resultCardDecoration; + final EdgeInsets? resultCardPadding; - final String language; + final String? language; - final LocationAccuracy desiredAccuracy; + final LocationAccuracy? desiredAccuracy; @override LocationPickerState createState() => LocationPickerState(); @@ -73,12 +73,12 @@ class LocationPicker extends StatefulWidget { class LocationPickerState extends State { /// Result returned after user completes selection - LocationResult locationResult; + LocationResult? locationResult; /// Overlay to display autocomplete suggestions - OverlayEntry overlayEntry; + OverlayEntry? overlayEntry; - List nearbyPlaces = List(); + List nearbyPlaces = []; /// Session token required for autocomplete API call String sessionToken = Uuid().generateV4(); @@ -94,7 +94,7 @@ class LocationPickerState extends State { /// Hides the autocomplete overlay void clearOverlay() { if (overlayEntry != null) { - overlayEntry.remove(); + overlayEntry!.remove(); overlayEntry = null; } } @@ -112,14 +112,14 @@ class LocationPickerState extends State { if (place.length < 1) return; - final RenderBox renderBox = context.findRenderObject(); + final RenderBox renderBox = context.findRenderObject() as RenderBox; Size size = renderBox.size; - final RenderBox appBarBox = appBarKey.currentContext.findRenderObject(); + final RenderBox? appBarBox = appBarKey.currentContext!.findRenderObject() as RenderBox?; overlayEntry = OverlayEntry( builder: (context) => Positioned( - top: appBarBox.size.height, + top: appBarBox!.size.height, width: size.width, child: Material( elevation: 1, @@ -146,7 +146,7 @@ class LocationPickerState extends State { ), ); - Overlay.of(context).insert(overlayEntry); + Overlay.of(context)!.insert(overlayEntry!); autoCompleteSearch(place); } @@ -159,7 +159,7 @@ class LocationPickerState extends State { // Currently, you can use components to filter by up to 5 countries. from https://developers.google.com/places/web-service/autocomplete String regionParam = countries?.isNotEmpty == true - ? "&components=country:${countries.sublist(0, min(countries.length, 5)).join('|country:')}" + ? "&components=country:${countries!.sublist(0, min(countries.length, 5)).join('|country:')}" : ""; var endpoint = @@ -169,12 +169,12 @@ class LocationPickerState extends State { "language=${widget.language}"; if (locationResult != null) { - endpoint += "&location=${locationResult.latLng.latitude}," + - "${locationResult.latLng.longitude}"; + endpoint += "&location=${locationResult!.latLng!.latitude}," + + "${locationResult!.latLng!.longitude}"; } LocationUtils.getAppHeaders() - .then((headers) => http.get(Uri.parse(endpoint), headers: headers)) + .then((headers) => http.get(Uri.parse(endpoint), headers: headers as Map?)) .then((response) { if (response.statusCode == 200) { Map data = jsonDecode(response.body); @@ -214,7 +214,7 @@ class LocationPickerState extends State { /// To navigate to the selected place from the autocomplete list to the map, /// the lat,lng is required. This method fetches the lat,lng of the place and /// proceeds to moving the map to that location. - void decodeAndSelectPlace(String placeId) { + void decodeAndSelectPlace(String? placeId) { clearOverlay(); final endpoint = @@ -223,7 +223,7 @@ class LocationPickerState extends State { '&language=${widget.language}'; LocationUtils.getAppHeaders() - .then((headers) => http.get(Uri.parse(endpoint), headers: headers)) + .then((headers) => http.get(Uri.parse(endpoint), headers: headers as Map?)) .then((response) { if (response.statusCode == 200) { Map location = @@ -240,17 +240,17 @@ class LocationPickerState extends State { /// Display autocomplete suggestions with the overlay. void displayAutoCompleteSuggestions(List suggestions) { - final RenderBox renderBox = context.findRenderObject(); + final RenderBox renderBox = context.findRenderObject() as RenderBox; Size size = renderBox.size; - final RenderBox appBarBox = appBarKey.currentContext.findRenderObject(); + final RenderBox? appBarBox = appBarKey.currentContext!.findRenderObject() as RenderBox?; clearOverlay(); overlayEntry = OverlayEntry( builder: (context) => Positioned( width: size.width, - top: appBarBox.size.height, + top: appBarBox!.size.height, child: Material( elevation: 1, child: Column( @@ -260,7 +260,7 @@ class LocationPickerState extends State { ), ); - Overlay.of(context).insert(overlayEntry); + Overlay.of(context)!.insert(overlayEntry!); } /// Utility function to get clean readable name of a location. First checks @@ -292,7 +292,7 @@ class LocationPickerState extends State { "location=${latLng.latitude},${latLng.longitude}&radius=150" + "&language=${widget.language}"; - return http.get(Uri.parse(endpoint), headers: headers); + return http.get(Uri.parse(endpoint), headers: headers as Map?); }).then((response) { if (response.statusCode == 200) { nearbyPlaces.clear(); @@ -330,14 +330,14 @@ class LocationPickerState extends State { "&language=${widget.language}"; final response = await http.get(Uri.parse(endpoint), - headers: await LocationUtils.getAppHeaders()); + headers: await (LocationUtils.getAppHeaders() as FutureOr?>)); if (response.statusCode == 200) { Map responseJson = jsonDecode(response.body); - String road; + String? road; - String placeId = responseJson['results'][0]['place_id']; + String? placeId = responseJson['results'][0]['place_id']; if (responseJson['status'] == 'REQUEST_DENIED') { road = 'REQUEST DENIED = please see log for more details'; @@ -352,9 +352,9 @@ class LocationPickerState extends State { setState(() { locationResult = LocationResult(); - locationResult.address = road; - locationResult.latLng = latLng; - locationResult.placeId = placeId; + locationResult!.address = road; + locationResult!.latLng = latLng; + locationResult!.placeId = placeId; }); } } @@ -362,7 +362,7 @@ class LocationPickerState extends State { /// Moves the camera to the provided location and updates other UI features to /// match the location. void moveToLocation(LatLng latLng) { - mapKey.currentState.mapController.future.then((controller) { + mapKey.currentState!.mapController.future.then((controller) { controller.animateCamera( CameraUpdate.newCameraPosition( CameraPosition( @@ -442,24 +442,24 @@ class LocationPickerState extends State { /// set [automaticallyAnimateToCurrentLocation] to false. /// /// -Future showLocationPicker( +Future showLocationPicker( BuildContext context, String apiKey, { LatLng initialCenter = const LatLng(45.521563, -122.677433), double initialZoom = 16, bool requiredGPS = false, - List countries, + List? countries, bool myLocationButtonEnabled = false, bool layersButtonEnabled = false, bool automaticallyAnimateToCurrentLocation = true, - String mapStylePath, + String? mapStylePath, Color appBarColor = Colors.transparent, - BoxDecoration searchBarBoxDecoration, - String hintText, - Widget resultCardConfirmIcon, - AlignmentGeometry resultCardAlignment, - EdgeInsetsGeometry resultCardPadding, - Decoration resultCardDecoration, + BoxDecoration? searchBarBoxDecoration, + String? hintText, + Widget? resultCardConfirmIcon, + AlignmentGeometry? resultCardAlignment, + EdgeInsetsGeometry? resultCardPadding, + Decoration? resultCardDecoration, String language = 'en', LocationAccuracy desiredAccuracy = LocationAccuracy.best, }) async { @@ -481,8 +481,8 @@ Future showLocationPicker( hintText: hintText, searchBarBoxDecoration: searchBarBoxDecoration, resultCardConfirmIcon: resultCardConfirmIcon, - resultCardAlignment: resultCardAlignment, - resultCardPadding: resultCardPadding, + resultCardAlignment: resultCardAlignment as Alignment?, + resultCardPadding: resultCardPadding as EdgeInsets?, resultCardDecoration: resultCardDecoration, countries: countries, language: language, diff --git a/lib/src/map.dart b/lib/src/map.dart index d0a0d454..726a17d6 100644 --- a/lib/src/map.dart +++ b/lib/src/map.dart @@ -21,7 +21,7 @@ import 'utils/location_utils.dart'; class MapPicker extends StatefulWidget { const MapPicker( this.apiKey, { - Key key, + Key? key, this.initialCenter, this.initialZoom, this.requiredGPS, @@ -42,27 +42,27 @@ class MapPicker extends StatefulWidget { final String apiKey; - final LatLng initialCenter; - final double initialZoom; + final LatLng? initialCenter; + final double? initialZoom; - final bool requiredGPS; - final bool myLocationButtonEnabled; - final bool layersButtonEnabled; - final bool automaticallyAnimateToCurrentLocation; + final bool? requiredGPS; + final bool? myLocationButtonEnabled; + final bool? layersButtonEnabled; + final bool? automaticallyAnimateToCurrentLocation; - final String mapStylePath; + final String? mapStylePath; - final Color appBarColor; - final BoxDecoration searchBarBoxDecoration; - final String hintText; - final Widget resultCardConfirmIcon; - final Alignment resultCardAlignment; - final Decoration resultCardDecoration; - final EdgeInsets resultCardPadding; + final Color? appBarColor; + final BoxDecoration? searchBarBoxDecoration; + final String? hintText; + final Widget? resultCardConfirmIcon; + final Alignment? resultCardAlignment; + final Decoration? resultCardDecoration; + final EdgeInsets? resultCardPadding; - final String language; + final String? language; - final LocationAccuracy desiredAccuracy; + final LocationAccuracy? desiredAccuracy; @override MapPickerState createState() => MapPickerState(); @@ -73,15 +73,15 @@ class MapPickerState extends State { MapType _currentMapType = MapType.normal; - String _mapStyle; + String? _mapStyle; - LatLng _lastMapPosition; + LatLng? _lastMapPosition; - Position _currentPosition; + Position? _currentPosition; - String _address; + String? _address; - String _placeId; + String? _placeId; void _onToggleMapTypePressed() { final MapType nextType = @@ -92,10 +92,10 @@ class MapPickerState extends State { // this also checks for location permission. Future _initCurrentLocation() async { - Position currentPosition; + Position? currentPosition; try { currentPosition = - await Geolocator.getCurrentPosition(desiredAccuracy: widget.desiredAccuracy); + await Geolocator.getCurrentPosition(desiredAccuracy: widget.desiredAccuracy!); d("position = $currentPosition"); setState(() => _currentPosition = currentPosition); @@ -124,11 +124,11 @@ class MapPickerState extends State { @override void initState() { super.initState(); - if (widget.automaticallyAnimateToCurrentLocation && !widget.requiredGPS) + if (widget.automaticallyAnimateToCurrentLocation! && !widget.requiredGPS!) _initCurrentLocation(); if (widget.mapStylePath != null) { - rootBundle.loadString(widget.mapStylePath).then((string) { + rootBundle.loadString(widget.mapStylePath!).then((string) { _mapStyle = string; }); } @@ -136,7 +136,7 @@ class MapPickerState extends State { @override Widget build(BuildContext context) { - if (widget.requiredGPS) { + if (widget.requiredGPS!) { _checkGeolocationPermission(); if (_currentPosition == null) _initCurrentLocation(); } @@ -148,8 +148,8 @@ class MapPickerState extends State { body: Builder( builder: (context) { if (_currentPosition == null && - widget.automaticallyAnimateToCurrentLocation && - widget.requiredGPS) { + widget.automaticallyAnimateToCurrentLocation! && + widget.requiredGPS!) { return const Center(child: CircularProgressIndicator()); } @@ -166,8 +166,8 @@ class MapPickerState extends State { GoogleMap( myLocationButtonEnabled: false, initialCameraPosition: CameraPosition( - target: widget.initialCenter, - zoom: widget.initialZoom, + target: widget.initialCenter!, + zoom: widget.initialZoom!, ), onMapCreated: (GoogleMapController controller) { mapController.complete(controller); @@ -226,7 +226,7 @@ class MapPickerState extends State { children: [ Flexible( flex: 20, - child: FutureLoadingBuilder>( + child: FutureLoadingBuilder>( future: getAddress(locationProvider.lastIdleLocation), mutable: true, loadingIndicator: Row( @@ -270,14 +270,14 @@ class MapPickerState extends State { ); } - Future> getAddress(LatLng location) async { + Future> getAddress(LatLng? location) async { try { final endpoint = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=${location?.latitude},${location?.longitude}' '&key=${widget.apiKey}&language=${widget.language}'; final response = jsonDecode((await http.get(Uri.parse(endpoint), - headers: await LocationUtils.getAppHeaders())) + headers: await (LocationUtils.getAppHeaders() as FutureOr?>))) .body); return { @@ -447,16 +447,16 @@ class MapPickerState extends State { class _MapFabs extends StatelessWidget { const _MapFabs({ - Key key, - @required this.myLocationButtonEnabled, - @required this.layersButtonEnabled, - @required this.onToggleMapTypePressed, - @required this.onMyLocationPressed, + Key? key, + required this.myLocationButtonEnabled, + required this.layersButtonEnabled, + required this.onToggleMapTypePressed, + required this.onMyLocationPressed, }) : assert(onToggleMapTypePressed != null), super(key: key); - final bool myLocationButtonEnabled; - final bool layersButtonEnabled; + final bool? myLocationButtonEnabled; + final bool? layersButtonEnabled; final VoidCallback onToggleMapTypePressed; final VoidCallback onMyLocationPressed; @@ -468,7 +468,7 @@ class _MapFabs extends StatelessWidget { margin: const EdgeInsets.only(top: kToolbarHeight + 24, right: 8), child: Column( children: [ - if (layersButtonEnabled) + if (layersButtonEnabled!) FloatingActionButton( onPressed: onToggleMapTypePressed, materialTapTargetSize: MaterialTapTargetSize.padded, @@ -476,7 +476,7 @@ class _MapFabs extends StatelessWidget { child: const Icon(Icons.layers), heroTag: "layers", ), - if (myLocationButtonEnabled) + if (myLocationButtonEnabled!) FloatingActionButton( onPressed: onMyLocationPressed, materialTapTargetSize: MaterialTapTargetSize.padded, diff --git a/lib/src/model/auto_comp_iete_item.dart b/lib/src/model/auto_comp_iete_item.dart index 6d5d840f..7ce61b80 100644 --- a/lib/src/model/auto_comp_iete_item.dart +++ b/lib/src/model/auto_comp_iete_item.dart @@ -2,17 +2,17 @@ /// into this model. class AutoCompleteItem { /// The id of the place. This helps to fetch the lat,lng of the place. - String id; + String? id; /// The text (name of place) displayed in the autocomplete suggestions list. - String text; + String? text; /// Assistive index to begin highlight of matched part of the [text] with /// the original query - int offset; + int? offset; /// Length of matched part of the [text] - int length; + int? length; @override String toString() { diff --git a/lib/src/model/location_result.dart b/lib/src/model/location_result.dart index b8c3248f..b35f30e9 100644 --- a/lib/src/model/location_result.dart +++ b/lib/src/model/location_result.dart @@ -5,13 +5,13 @@ class LocationResult { /// The human readable name of the location. This is primarily the /// name of the road. But in cases where the place was selected from Nearby /// places list, we use the name provided on the list item. - String address; // or road + String? address; // or road /// Google Maps place ID - String placeId; + String? placeId; /// Latitude/Longitude of the selected location. - LatLng latLng; + LatLng? latLng; LocationResult({this.latLng, this.address, this.placeId}); diff --git a/lib/src/model/nearby_place.dart b/lib/src/model/nearby_place.dart index 6a18f216..11bfbf1e 100644 --- a/lib/src/model/nearby_place.dart +++ b/lib/src/model/nearby_place.dart @@ -4,14 +4,14 @@ import 'package:google_maps_flutter/google_maps_flutter.dart'; class NearbyPlace { /// The human-readable name of the location provided. This value is provided /// for [LocationResult.address] when the user selects this nearby place. - String name; + String? name; /// The icon identifying the kind of place provided. Eg. lodging, chapel, /// hospital, etc. - String icon; + String? icon; // Latitude/Longitude of the provided location. - LatLng latLng; + LatLng? latLng; @override String toString() { diff --git a/lib/src/providers/location_provider.dart b/lib/src/providers/location_provider.dart index df4b2aef..0ef16d33 100644 --- a/lib/src/providers/location_provider.dart +++ b/lib/src/providers/location_provider.dart @@ -6,11 +6,11 @@ class LocationProvider extends ChangeNotifier { static LocationProvider of(BuildContext context, {bool listen = true}) => Provider.of(context, listen: listen); - LatLng _lastIdleLocation; + LatLng? _lastIdleLocation; - LatLng get lastIdleLocation => _lastIdleLocation; + LatLng? get lastIdleLocation => _lastIdleLocation; - void setLastIdleLocation(LatLng lastIdleLocation) { + void setLastIdleLocation(LatLng? lastIdleLocation) { if (_lastIdleLocation != lastIdleLocation) { _lastIdleLocation = lastIdleLocation; notifyListeners(); diff --git a/lib/src/rich_suggestion.dart b/lib/src/rich_suggestion.dart index a7472641..bc4d33c0 100644 --- a/lib/src/rich_suggestion.dart +++ b/lib/src/rich_suggestion.dart @@ -33,7 +33,7 @@ class RichSuggestion extends StatelessWidget { final List result = []; String startText = - autoCompleteItem.text.substring(0, autoCompleteItem.offset); + autoCompleteItem.text!.substring(0, autoCompleteItem.offset); if (startText.isNotEmpty) { result.add( TextSpan( @@ -47,8 +47,8 @@ class RichSuggestion extends StatelessWidget { ); } - String boldText = autoCompleteItem.text.substring(autoCompleteItem.offset, - autoCompleteItem.offset + autoCompleteItem.length); + String boldText = autoCompleteItem.text!.substring(autoCompleteItem.offset!, + autoCompleteItem.offset! + autoCompleteItem.length!); result.add( TextSpan( @@ -63,8 +63,8 @@ class RichSuggestion extends StatelessWidget { String remainingText = this .autoCompleteItem - .text - .substring(autoCompleteItem.offset + autoCompleteItem.length); + .text! + .substring(autoCompleteItem.offset! + autoCompleteItem.length!); result.add( TextSpan( text: remainingText, diff --git a/lib/src/search_input.dart b/lib/src/search_input.dart index 9d7ba047..00041dea 100644 --- a/lib/src/search_input.dart +++ b/lib/src/search_input.dart @@ -7,16 +7,16 @@ import 'package:google_map_location_picker/generated/l10n.dart'; class SearchInput extends StatefulWidget { SearchInput( this.onSearchInput, { - Key key, + Key? key, this.searchInputKey, this.boxDecoration, this.hintText, }) : super(key: key); final ValueChanged onSearchInput; - final Key searchInputKey; - final BoxDecoration boxDecoration; - final String hintText; + final Key? searchInputKey; + final BoxDecoration? boxDecoration; + final String? hintText; @override State createState() => SearchInputState(); @@ -25,7 +25,7 @@ class SearchInput extends StatefulWidget { class SearchInputState extends State { TextEditingController editController = TextEditingController(); - Timer debouncer; + Timer? debouncer; bool hasSearchEntry = false; @@ -51,7 +51,7 @@ class SearchInputState extends State { } if (debouncer?.isActive ?? false) { - debouncer.cancel(); + debouncer!.cancel(); } debouncer = Timer(Duration(milliseconds: 500), () { diff --git a/lib/src/utils/loading_builder.dart b/lib/src/utils/loading_builder.dart index ec1d09ce..4ca7c5bb 100644 --- a/lib/src/utils/loading_builder.dart +++ b/lib/src/utils/loading_builder.dart @@ -10,10 +10,10 @@ typedef WidgetBuilder = Widget Function(BuildContext context, T snapshot); class FutureLoadingBuilder extends StatefulWidget { const FutureLoadingBuilder({ - Key key, - @required this.future, + Key? key, + required this.future, this.initialData, - @required this.builder, + required this.builder, this.mutable = false, this.loadingIndicator, }) : assert(builder != null), @@ -35,22 +35,22 @@ class FutureLoadingBuilder extends StatefulWidget { /// provided to the [builder] will become null, regardless of [initialData]. /// (The error itself will be available in [AsyncSnapshot.error], and /// [AsyncSnapshot.hasError] will be true.) - final T initialData; + final T? initialData; /// default is true /// /// set to false if the future will change. final bool mutable; - final Widget loadingIndicator; + final Widget? loadingIndicator; @override _FutureLoadingBuilderState createState() => _FutureLoadingBuilderState(); } -class _FutureLoadingBuilderState extends State> { - Future future; +class _FutureLoadingBuilderState extends State> { + Future? future; @override void initState() { @@ -60,7 +60,7 @@ class _FutureLoadingBuilderState extends State> { @override Widget build(BuildContext context) { - return FutureBuilder( + return FutureBuilder( future: widget.mutable ? widget.future : future, initialData: widget.initialData, builder: (BuildContext context, AsyncSnapshot snapshot) { diff --git a/lib/src/utils/location_utils.dart b/lib/src/utils/location_utils.dart index f5209277..68451f12 100644 --- a/lib/src/utils/location_utils.dart +++ b/lib/src/utils/location_utils.dart @@ -5,9 +5,9 @@ import 'package:flutter/services.dart'; class LocationUtils { static const _platform = const MethodChannel('google_map_location_picker'); - static Map _appHeaderCache = {}; + static Map _appHeaderCache = {}; - static Future> getAppHeaders() async { + static Future> getAppHeaders() async { if (_appHeaderCache.isEmpty) { PackageInfo packageInfo = await PackageInfo.fromPlatform(); @@ -16,7 +16,7 @@ class LocationUtils { "X-Ios-Bundle-Identifier": packageInfo.packageName, }; } else if (Platform.isAndroid) { - String sha1; + String? sha1; try { sha1 = await _platform.invokeMethod( 'getSigningCertSha1', packageInfo.packageName); diff --git a/pubspec.yaml b/pubspec.yaml index 1fe65d8f..0418cd56 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/humazed/google_map_location_picker # flutter pub pub publish --dry-run environment: - sdk: ">=2.2.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' flutter: ">=2.0.0" dependencies: From 2a4d1a67bfa1098a7d6a54e1740c88e3fe693792 Mon Sep 17 00:00:00 2001 From: Bhargav B L Date: Tue, 22 Jun 2021 12:31:23 +0530 Subject: [PATCH 4/7] Type casting errors due to null safety fixed --- .../android/app/src/main/AndroidManifest.xml | 8 ++--- .../app/src/main/res/values/styles.xml | 18 +++++++++++ example/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/lib/generated/i18n.dart | 32 +++++++++---------- example/lib/main.dart | 6 ++-- example/pubspec.lock | 11 +++++-- example/pubspec.yaml | 2 +- lib/src/map.dart | 12 ++++--- lib/src/utils/loading_builder.dart | 6 ++-- lib/src/utils/location_utils.dart | 6 ++-- pubspec.lock | 7 ++++ pubspec.yaml | 1 + 13 files changed, 74 insertions(+), 39 deletions(-) create mode 100644 example/android/app/src/main/res/values/styles.xml diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index a41588c0..7cafa901 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -38,11 +38,11 @@ - + + + + android:value="API_KEY" /> diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..1f83a33f --- /dev/null +++ b/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/build.gradle b/example/android/build.gradle index 56ace55b..7c1a7619 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.6.3' + classpath 'com.android.tools.build:gradle:4.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 56228224..82d78d74 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip diff --git a/example/lib/generated/i18n.dart b/example/lib/generated/i18n.dart index b5e27a19..5636c73b 100644 --- a/example/lib/generated/i18n.dart +++ b/example/lib/generated/i18n.dart @@ -11,12 +11,12 @@ import 'package:flutter/material.dart'; class S implements WidgetsLocalizations { const S(); - static S current; + static S? current; static const GeneratedLocalizationsDelegate delegate = GeneratedLocalizationsDelegate(); - static S of(BuildContext context) => Localizations.of(context, S); + static S? of(BuildContext context) => Localizations.of(context, S); @override TextDirection get textDirection => TextDirection.ltr; @@ -33,7 +33,7 @@ class $en extends S { const $en(); } -class GeneratedLocalizationsDelegate extends LocalizationsDelegate { +class GeneratedLocalizationsDelegate extends LocalizationsDelegate { const GeneratedLocalizationsDelegate(); List get supportedLocales { @@ -44,8 +44,8 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate { } LocaleListResolutionCallback listResolution( - {Locale fallback, bool withCountry = true}) { - return (List locales, Iterable supported) { + {Locale? fallback, bool withCountry = true}) { + return (List? locales, Iterable supported) { if (locales == null || locales.isEmpty) { return fallback ?? supported.first; } else { @@ -55,29 +55,29 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate { } LocaleResolutionCallback resolution( - {Locale fallback, bool withCountry = true}) { - return (Locale locale, Iterable supported) { + {Locale? fallback, bool withCountry = true}) { + return (Locale? locale, Iterable supported) { return _resolve(locale, fallback, supported, withCountry); }; } @override - Future load(Locale locale) { - final String lang = getLang(locale); + Future load(Locale locale) { + final String? lang = getLang(locale); if (lang != null) { switch (lang) { case "ar": S.current = const $ar(); - return SynchronousFuture(S.current); + return SynchronousFuture(S.current); case "en": S.current = const $en(); - return SynchronousFuture(S.current); + return SynchronousFuture(S.current); default: // NO-OP. } } S.current = const S(); - return SynchronousFuture(S.current); + return SynchronousFuture(S.current); } @override @@ -89,7 +89,7 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate { /// /// Internal method to resolve a locale from a list of locales. /// - Locale _resolve(Locale locale, Locale fallback, Iterable supported, + Locale _resolve(Locale? locale, Locale? fallback, Iterable supported, bool withCountry) { if (locale == null || !_isSupported(locale, withCountry)) { return fallback ?? supported.first; @@ -125,7 +125,7 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate { // If no country requirement is requested, check if this locale has no country. if (true != withCountry && (supportedLocale.countryCode == null || - supportedLocale.countryCode.isEmpty)) { + supportedLocale.countryCode!.isEmpty)) { return true; } } @@ -134,8 +134,8 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate { } } -String getLang(Locale l) => l == null +String? getLang(Locale l) => l == null ? null - : l.countryCode != null && l.countryCode.isEmpty + : l.countryCode != null && l.countryCode!.isEmpty ? l.languageCode : l.toString(); diff --git a/example/lib/main.dart b/example/lib/main.dart index 67c1c7bf..b2c19b27 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,7 +15,7 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - LocationResult _pickedLocation; + LocationResult? _pickedLocation; @override Widget build(BuildContext context) { @@ -49,9 +49,9 @@ class _MyAppState extends State { children: [ RaisedButton( onPressed: () async { - LocationResult result = await showLocationPicker( + LocationResult? result = await showLocationPicker( context, - "", + "API_KEY", initialCenter: LatLng(31.1975844, 29.9598339), // automaticallyAnimateToCurrentLocation: true, // mapStylePath: 'assets/mapStyle.json', diff --git a/example/pubspec.lock b/example/pubspec.lock index 9cc379c6..36b89c8c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -91,6 +91,13 @@ packages: description: flutter source: sdk version: "0.0.0" + geocode: + dependency: transitive + description: + name: geocode + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" geolocator: dependency: transitive description: @@ -132,7 +139,7 @@ packages: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" http: dependency: transitive description: @@ -202,7 +209,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.11.1" platform: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 996c53f7..096e2893 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: 'none' version: 1.0.0 environment: - sdk: ">=2.2.2 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: diff --git a/lib/src/map.dart b/lib/src/map.dart index 726a17d6..209790cf 100644 --- a/lib/src/map.dart +++ b/lib/src/map.dart @@ -226,7 +226,7 @@ class MapPickerState extends State { children: [ Flexible( flex: 20, - child: FutureLoadingBuilder>( + child: FutureLoadingBuilder?>( future: getAddress(locationProvider.lastIdleLocation), mutable: true, loadingIndicator: Row( @@ -236,7 +236,7 @@ class MapPickerState extends State { ], ), builder: (context, data) { - _address = data["address"]; + _address = data!["address"]; _placeId = data["placeId"]; return Text( _address ?? @@ -270,22 +270,24 @@ class MapPickerState extends State { ); } - Future> getAddress(LatLng? location) async { + Future?> getAddress(LatLng? location) async { try { final endpoint = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=${location?.latitude},${location?.longitude}' '&key=${widget.apiKey}&language=${widget.language}'; final response = jsonDecode((await http.get(Uri.parse(endpoint), - headers: await (LocationUtils.getAppHeaders() as FutureOr?>))) + headers: await (LocationUtils.getAppHeaders()))) .body); + print("BLB data ${response}"); + return { "placeId": response['results'][0]['place_id'], "address": response['results'][0]['formatted_address'] }; } catch (e) { - print(e); + print("BLB $e"); } return {"placeId": null, "address": null}; diff --git a/lib/src/utils/loading_builder.dart b/lib/src/utils/loading_builder.dart index 4ca7c5bb..1eb87a24 100644 --- a/lib/src/utils/loading_builder.dart +++ b/lib/src/utils/loading_builder.dart @@ -26,7 +26,7 @@ class FutureLoadingBuilder extends StatefulWidget { /// null, the data provided to the [builder] will be set to [initialData]. final Future future; - final WidgetBuilder builder; + final WidgetBuilder? builder; /// The data that will be used to create the snapshots provided until a /// non-null [future] has completed. @@ -96,9 +96,9 @@ class _FutureLoadingBuilderState extends State> { } } - return widget.builder(context, snapshot.data); + return widget.builder!(context, snapshot.data); } - return widget.builder(context, snapshot.data); + return widget.builder!(context, snapshot.data); }, ); } diff --git a/lib/src/utils/location_utils.dart b/lib/src/utils/location_utils.dart index 68451f12..1904e9f9 100644 --- a/lib/src/utils/location_utils.dart +++ b/lib/src/utils/location_utils.dart @@ -5,9 +5,9 @@ import 'package:flutter/services.dart'; class LocationUtils { static const _platform = const MethodChannel('google_map_location_picker'); - static Map _appHeaderCache = {}; + static Map _appHeaderCache = {}; - static Future> getAppHeaders() async { + static Future?> getAppHeaders() async { if (_appHeaderCache.isEmpty) { PackageInfo packageInfo = await PackageInfo.fromPlatform(); @@ -16,7 +16,7 @@ class LocationUtils { "X-Ios-Bundle-Identifier": packageInfo.packageName, }; } else if (Platform.isAndroid) { - String? sha1; + String sha1=""; try { sha1 = await _platform.invokeMethod( 'getSigningCertSha1', packageInfo.packageName); diff --git a/pubspec.lock b/pubspec.lock index 7dc533fa..aba6defc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -84,6 +84,13 @@ packages: description: flutter source: sdk version: "0.0.0" + geocode: + dependency: "direct main" + description: + name: geocode + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" geolocator: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 0418cd56..df255329 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,7 @@ dependencies: http: ^0.13.3 stack_trace: ^1.10.0 package_info: ^2.0.2 + geocode: 1.0.1 dev_dependencies: flutter_test: From 15d03bd3cc09fe583fe60e0ff5ba2d2eff47cf70 Mon Sep 17 00:00:00 2001 From: Bhargav B L Date: Tue, 22 Jun 2021 12:41:23 +0530 Subject: [PATCH 5/7] Type casting errors due to null safety fixed --- pubspec.lock | 7 ------- pubspec.yaml | 1 - 2 files changed, 8 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index aba6defc..7dc533fa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -84,13 +84,6 @@ packages: description: flutter source: sdk version: "0.0.0" - geocode: - dependency: "direct main" - description: - name: geocode - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" geolocator: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index df255329..0418cd56 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,6 @@ dependencies: http: ^0.13.3 stack_trace: ^1.10.0 package_info: ^2.0.2 - geocode: 1.0.1 dev_dependencies: flutter_test: From c02ffde197f32cb011dba6405b800ae0d467e345 Mon Sep 17 00:00:00 2001 From: bhargav22 Date: Sun, 27 Feb 2022 15:25:42 +0530 Subject: [PATCH 6/7] package upgrades --- .../ios/Flutter/flutter_export_environment.sh | 1 - example/pubspec.lock | 72 +++++++++++-------- pubspec.lock | 69 +++++++++++------- pubspec.yaml | 8 +-- 4 files changed, 92 insertions(+), 58 deletions(-) diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index d04202e9..f5b00c5f 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -5,7 +5,6 @@ export "FLUTTER_APPLICATION_PATH=/Users/blb/Development/google_map_location_pick export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build/ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1.0.0" export "DART_OBFUSCATION=false" diff --git a/example/pubspec.lock b/example/pubspec.lock index 36b89c8c..39edd966 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -14,7 +14,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -28,14 +28,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -91,34 +91,48 @@ packages: description: flutter source: sdk version: "0.0.0" - geocode: + geolocator: dependency: transitive description: - name: geocode + name: geolocator url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" - geolocator: + version: "8.2.0" + geolocator_android: dependency: transitive description: - name: geolocator + name: geolocator_android url: "https://pub.dartlang.org" source: hosted - version: "7.1.0" + version: "3.1.0" + geolocator_apple: + dependency: transitive + description: + name: geolocator_apple + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1+1" geolocator_platform_interface: dependency: transitive description: name: geolocator_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "4.0.3" geolocator_web: dependency: transitive description: name: geolocator_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.1.4" + geolocator_windows: + dependency: transitive + description: + name: geolocator_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0" google_map_location_picker: dependency: "direct dev" description: @@ -132,21 +146,21 @@ packages: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.1.1" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.5" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.3" + version: "0.13.4" http_parser: dependency: transitive description: @@ -174,14 +188,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" nested: dependency: transitive description: @@ -203,13 +224,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.1" platform: dependency: transitive description: @@ -223,14 +237,14 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.2" provider: dependency: transitive description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "6.0.2" sky_engine: dependency: transitive description: flutter @@ -284,7 +298,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.8" typed_data: dependency: transitive description: @@ -298,7 +312,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=2.15.0 <3.0.0" + flutter: ">=2.8.0" diff --git a/pubspec.lock b/pubspec.lock index 7dc533fa..77f0dfc5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -14,7 +14,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -28,14 +28,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -90,42 +90,63 @@ packages: name: geolocator url: "https://pub.dartlang.org" source: hosted - version: "7.1.0" + version: "8.2.0" + geolocator_android: + dependency: transitive + description: + name: geolocator_android + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + geolocator_apple: + dependency: transitive + description: + name: geolocator_apple + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1+1" geolocator_platform_interface: dependency: transitive description: name: geolocator_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "4.0.3" geolocator_web: dependency: transitive description: name: geolocator_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.1.4" + geolocator_windows: + dependency: transitive + description: + name: geolocator_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0" google_maps_flutter: dependency: "direct main" description: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.1.1" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.5" http: dependency: "direct main" description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.3" + version: "0.13.4" http_parser: dependency: transitive description: @@ -153,14 +174,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" nested: dependency: transitive description: @@ -182,13 +210,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" platform: dependency: transitive description: @@ -202,14 +223,14 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.2" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "6.0.2" sky_engine: dependency: transitive description: flutter @@ -263,7 +284,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.8" typed_data: dependency: transitive description: @@ -277,7 +298,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=2.15.0 <3.0.0" + flutter: ">=2.8.0" diff --git a/pubspec.yaml b/pubspec.yaml index 0418cd56..604671ec 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,11 +16,11 @@ dependencies: sdk: flutter intl: ^0.17.0 - google_maps_flutter: ^2.0.6 - geolocator: ^7.1.0 + google_maps_flutter: ^2.1.1 + geolocator: ^8.2.0 android_intent: ^2.0.2 - provider: ^5.0.0 - http: ^0.13.3 + provider: ^6.0.2 + http: ^0.13.4 stack_trace: ^1.10.0 package_info: ^2.0.2 From b3142d6f449899b323d6790f5d31265378d36aae Mon Sep 17 00:00:00 2001 From: bhargav22 Date: Sun, 27 Feb 2022 16:33:49 +0530 Subject: [PATCH 7/7] package upgrades --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 68a64275..fcd7dcdc 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,7 +2,7 @@ group 'com.humazed.google_map_location_picker' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.3.31' + ext.kotlin_version = '1.3.40' repositories { google() jcenter()