Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"geolocator_apple","path":"/home/munsif/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.2/","native_build":true,"dependencies":[]},{"name":"google_maps_flutter_ios","path":"/home/munsif/.pub-cache/hosted/pub.dev/google_maps_flutter_ios-2.3.3/","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"/home/munsif/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.17/","native_build":true,"dependencies":[]},{"name":"geolocator_android","path":"/home/munsif/.pub-cache/hosted/pub.dev/geolocator_android-4.4.0/","native_build":true,"dependencies":[]},{"name":"google_maps_flutter_android","path":"/home/munsif/.pub-cache/hosted/pub.dev/google_maps_flutter_android-2.6.0/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]}],"macos":[{"name":"geolocator_apple","path":"/home/munsif/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.2/","native_build":true,"dependencies":[]}],"linux":[],"windows":[{"name":"geolocator_windows","path":"/home/munsif/.pub-cache/hosted/pub.dev/geolocator_windows-0.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"geolocator_web","path":"/home/munsif/.pub-cache/hosted/pub.dev/geolocator_web-2.2.0/","dependencies":[]},{"name":"google_maps_flutter_web","path":"/home/munsif/.pub-cache/hosted/pub.dev/google_maps_flutter_web-0.5.4+2/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"geolocator","dependencies":["geolocator_android","geolocator_apple","geolocator_web","geolocator_windows"]},{"name":"geolocator_android","dependencies":[]},{"name":"geolocator_apple","dependencies":[]},{"name":"geolocator_web","dependencies":[]},{"name":"geolocator_windows","dependencies":[]},{"name":"google_maps_flutter","dependencies":["google_maps_flutter_android","google_maps_flutter_ios","google_maps_flutter_web"]},{"name":"google_maps_flutter_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"google_maps_flutter_ios","dependencies":[]},{"name":"google_maps_flutter_web","dependencies":[]}],"date_created":"2023-12-21 09:22:27.324378","version":"3.16.4"}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this file to .gitignore

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry i forgot to add ! with the condition.
it should be

if(!context.mounted){
   return;
}

Copy link
Author

@Munsif-Ali Munsif-Ali Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this file to .gitignore

i done the changes can you review it.

2 changes: 1 addition & 1 deletion example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PickerDemoState extends State<PickerDemo> {
return Scaffold(
appBar: AppBar(title: const Text('Picker Example')),
body: Center(
child: FlatButton(
child: ElevatedButton(
child: Text("Pick Delivery location"),
onPressed: () {
showPlacePicker();
Expand Down
24 changes: 9 additions & 15 deletions lib/widgets/place_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,8 @@ class PlacePickerState extends State<PlacePicker> {
super.initState();
if (widget.displayLocation == null) {
_getCurrentLocation().then((value) {
if (value != null) {
setState(() {
_currentLocation = value;
});
} else {
//Navigator.of(context).pop(null);
print("getting current location null");
}
setState(() {
_currentLocation = value;
_loadMap = true;
});
}).catchError((e) {
Expand Down Expand Up @@ -137,7 +130,7 @@ class PlacePickerState extends State<PlacePicker> {
locationResult = null;
_delayedPop();
return Future.value(false);
} else {
} else {
return Future.value(true);
}
},
Expand Down Expand Up @@ -193,7 +186,8 @@ class PlacePickerState extends State<PlacePicker> {
Padding(
child: Text(widget.localizationItem!.nearBy,
style: TextStyle(fontSize: 16)),
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 8),
padding:
EdgeInsets.symmetric(horizontal: 24, vertical: 8),
),
Expanded(
child: ListView(
Expand Down Expand Up @@ -236,7 +230,7 @@ class PlacePickerState extends State<PlacePicker> {

previousSearchTerm = place;

if (context == null) {
if (context.mounted) {
return;
}

Expand Down Expand Up @@ -281,7 +275,7 @@ class PlacePickerState extends State<PlacePicker> {
),
);

Overlay.of(context)?.insert(this.overlayEntry!);
Overlay.of(context).insert(this.overlayEntry!);

autoCompleteSearch(place);
}
Expand Down Expand Up @@ -397,7 +391,7 @@ class PlacePickerState extends State<PlacePicker> {
),
);

Overlay.of(context)?.insert(this.overlayEntry!);
Overlay.of(context).insert(this.overlayEntry!);
}

/// Utility function to get clean readable name of a location. First checks
Expand Down Expand Up @@ -512,7 +506,7 @@ class PlacePickerState extends State<PlacePicker> {
result['address_components'].length > 0) {
for (var i = 0; i < result['address_components'].length; i++) {
var tmp = result['address_components'][i];
var types = tmp["types"] as List<dynamic>;
var types = tmp["types"] as List<dynamic>?;
var shortName = tmp['short_name'];
if (types == null) {
continue;
Expand Down Expand Up @@ -645,7 +639,7 @@ class PlacePickerState extends State<PlacePicker> {
//moveToLocation(target);
print('target:$target');
return target;
} on TimeoutException catch (e) {
} on TimeoutException catch (_) {
final locationData = await Geolocator.getLastKnownPosition();
if (locationData != null) {
return LatLng(locationData.latitude, locationData.longitude);
Expand Down
Loading