Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.buildlog/
.history
.svn/
.flutter-plugins-dependencies

# IntelliJ related
*.iml
Expand Down
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