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 .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":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_maps_flutter_ios","path":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/google_maps_flutter_ios-2.6.0/","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.19/","native_build":true,"dependencies":[]},{"name":"geolocator_android","path":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/geolocator_android-4.6.0/","native_build":true,"dependencies":[]},{"name":"google_maps_flutter_android","path":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/google_maps_flutter_android-2.8.0/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]}],"macos":[{"name":"geolocator_apple","path":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]}],"linux":[],"windows":[{"name":"geolocator_windows","path":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/geolocator_windows-0.2.3/","native_build":true,"dependencies":[]}],"web":[{"name":"geolocator_web","path":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/geolocator_web-4.0.0/","dependencies":[]},{"name":"google_maps_flutter_web","path":"/Users/muhammadfarooqiqbal/.pub-cache/hosted/pub.dev/google_maps_flutter_web-0.5.7/","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":"2024-05-20 19:47:49.893388","version":"3.22.0"}
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: TextButton(
child: Text("Pick Delivery location"),
onPressed: () {
showPlacePicker();
Expand Down
40 changes: 20 additions & 20 deletions lib/widgets/place_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import '../uuid.dart';
///
/// API key provided should have `Maps SDK for Android`, `Maps SDK for iOS`
/// and `Places API` enabled for it
// ignore: must_be_immutable
class PlacePicker extends StatefulWidget {
/// API key generated from Google Cloud Console. You can get an API key
/// [here](https://cloud.google.com/maps-platform/)
Expand All @@ -30,8 +31,12 @@ class PlacePicker extends StatefulWidget {
LocalizationItem? localizationItem;
LatLng defaultLocation = LatLng(10.5381264, 73.8827201);

PlacePicker(this.apiKey,
{this.displayLocation, this.localizationItem, LatLng? defaultLocation}) {
PlacePicker(
this.apiKey, {
this.displayLocation,
this.localizationItem,
LatLng? defaultLocation,
}) {
if (this.localizationItem == null) {
this.localizationItem = new LocalizationItem();
}
Expand Down Expand Up @@ -90,14 +95,9 @@ 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;
});
setState(() {
_loadMap = true;
});
Expand Down Expand Up @@ -137,7 +137,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 +193,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,9 +237,9 @@ class PlacePickerState extends State<PlacePicker> {

previousSearchTerm = place;

if (context == null) {
return;
}
// if (context == null) {
// return;
// }

clearOverlay();

Expand Down Expand Up @@ -281,7 +282,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 +398,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 @@ -514,9 +515,6 @@ class PlacePickerState extends State<PlacePicker> {
var tmp = result['address_components'][i];
var types = tmp["types"] as List<dynamic>;
var shortName = tmp['short_name'];
if (types == null) {
continue;
}
if (i == 0) {
// [street_number]
name = shortName;
Expand Down Expand Up @@ -648,8 +646,10 @@ class PlacePickerState extends State<PlacePicker> {
} on TimeoutException catch (e) {
final locationData = await Geolocator.getLastKnownPosition();
if (locationData != null) {
print("Error: $e");
return LatLng(locationData.latitude, locationData.longitude);
} else {
print("Error: $e");
return widget.defaultLocation;
}
}
Expand Down
15 changes: 10 additions & 5 deletions lib/widgets/rich_suggestion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@ class RichSuggestion extends StatelessWidget {
final List<TextSpan> result = [];
final style = TextStyle(color: Colors.grey, fontSize: 15);

final startText = autoCompleteItem.text?.substring(0, autoCompleteItem.offset);
final startText =
autoCompleteItem.text?.substring(0, autoCompleteItem.offset);
if (startText?.isNotEmpty == true) {
result.add(TextSpan(text: startText, style: style));
}

final boldText =
autoCompleteItem.text?.substring(autoCompleteItem.offset!, autoCompleteItem.offset! + autoCompleteItem.length!);
final boldText = autoCompleteItem.text?.substring(autoCompleteItem.offset!,
autoCompleteItem.offset! + autoCompleteItem.length!);
result.add(
TextSpan(text: boldText, style: style.copyWith(color: Theme.of(context).textTheme.bodyText1?.color)),
TextSpan(
text: boldText,
style: style.copyWith(
color: Theme.of(context).textTheme.bodySmall?.color)),
);

final remainingText = autoCompleteItem.text?.substring(autoCompleteItem.offset! + autoCompleteItem.length!);
final remainingText = autoCompleteItem.text
?.substring(autoCompleteItem.offset! + autoCompleteItem.length!);
result.add(TextSpan(text: remainingText, style: style));

return result;
Expand Down
6 changes: 4 additions & 2 deletions lib/widgets/search_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ class SearchInputState extends State<SearchInput> {
padding: EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: <Widget>[
Icon(Icons.search, color: Theme.of(context).textTheme.bodyText1?.color),
Icon(Icons.search,
color: Theme.of(context).textTheme.bodySmall?.color),
SizedBox(width: 8),
Expanded(
child: TextField(
decoration: InputDecoration(hintText: "Search place", border: InputBorder.none),
decoration: InputDecoration(
hintText: "Search place", border: InputBorder.none),
controller: this.editController,
onChanged: (value) {
setState(() {
Expand Down
Loading