shrutimahajan / google-autocomplete-textfield-flutter Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
google_places_flutter >=2.0.0 depends on dio ^3.0.10 and private_therapy_clinic depends on dio ^4.0.0-prev2, google_places_flutter >=2.0.0 is forbidden.
How to add
decoration: InputDecoration(
hintText: "Arahan",
hintStyle: TextStyle(color: Colors.blue),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
color: Colors.blue[600], width: 1),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
color: Colors.blue[600], width: 1),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
color: Colors.blue[600], width: 1),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
color: Colors.blue[600], width: 1),
),
),
in the GooglePlaceAutoCompleteTextField ?
I am facing an issue when the number of countries in list are more than five, the search does not work.
There's no way to show in overlay mode since you have to be reorganizing widgets for right position.
Please add the language parameter to the widget paramenters. That would help a lot.
I tried using my custom input decoration but the enclosing container and row of the text field won't allow me to have the desired result. Things like error border will have issues due to the enclosing container's decoration, the container colour wont change with error when validating. Please could you remove the container because i had to manually edit your code before i could use it. I can create a PR Later.. Thank you.
Hi I open this Issue cause need to fix bug when empty text call to api.
Reproduce: Fast typing on search address text and backspace before bounce reached.
Here is I open MR to fix this:
#51
While searching for "Canada" with placeID: ChIJ2WrMN9MDDUsRpY9Doiq3aJk the following unhandled exception occurs:
E/flutter (29191): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'int' is not a subtype of type 'double?'
E/flutter (29191): #0 new Location.fromJson (package:google_places_flutter/model/place_details.dart:172:5)
E/flutter (29191): #1 new Viewport.fromJson (package:google_places_flutter/model/place_details.dart:192:15)
E/flutter (29191): #2 new Geometry.fromJson (package:google_places_flutter/model/place_details.dart:149:15)
E/flutter (29191): #3 new Result.fromJson (package:google_places_flutter/model/place_details.dart:68:15)
E/flutter (29191): #4 new PlaceDetails.fromJson (package:google_places_flutter/model/place_details.dart:9:38)
E/flutter (29191): #5 _GooglePlaceAutoCompleteTextFieldState.getPlaceDetailsFromPlaceId (package:google_places_flutter/google_places_flutter.dart:254:46)
This is due the lat/lng of the viewport of this place, as they have no decimals, they are treated as int. When getPlaceDetailsFromPlaceId calls the following url:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ2WrMN9MDDUsRpY9Doiq3aJk&key=AIzaSyAy3LfcYEWsBbtsmLwXfA5nmW3bBqTY7K4
it fails to parse:
viewport
northeast
lat 70
lng -50
southwest
lat 42
lng -142
at place_details.dart line #172:
lat = json['lat'];
it could be fixed with the following change, to this and the following line:
lat = double.parse(json['lat'].toString());
lng = double.parse(json['lng'].toString());
Thanks!
baseUrl is hardcoded in two places in google_places_flutter.dart
Can this be added as a parameter to allow for proxying of the Google Maps API?
When I assign "false" to isCrossBtnShown, it still shows the cross button.
I want to allow users to search places all over the world except India. I created a list of country codes except "in" and used it in the widget. However, when I entered a keyword, it didn't suggest anything.
When i type some keyword suggestion pops but when i click lat lng is always null
description has value
Getting this error on the console while using the component.
Access to XMLHttpRequest at 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=f&key=<key>&components=country:ng' from origin 'https://api.flutlab.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The key, in the error message, was changed by me.
When selecting a prediction, the prediction text is put into the text field. This might trigger a text change and therefore another prediction search with just 1 result matching the result from the first search.
GooglePlaceAutoCompleteTextField(
textEditingController: controller,
googleAPIKey: googleApikey,
inputDecoration: InputDecoration(),
debounceTime: 800, // default 600 ms,
countries: ["ng"],// optional by default null is set
isLatLngRequired: true,// if you required coordinates from place detail
getPlaceDetailWithLatLng: (Prediction prediction) {
print("placeDetails" + prediction.lng.toString());
}, // this callback is called when isLatLngRequired is true
itmClick: (Prediction prediction) {
controller.text=prediction.description;
controller.selection = TextSelection.fromPosition(TextPosition(offset: prediction.description.length));
}
)
I get error from this code.
Just used this code from sample.
Please let me know what is the issue.
Hello,
Please upgrade latest dio plugin, because I have used latest dio version in my flutter project and latest flutter version.
Hi,
Thanks for this wonderful plugin.
We recently migrated the google_places_flutter plugin from version 1.0.5 to 2.0.2 and the accuracy of predication has been degraded.
The screenshot from 1.0.5 seems to return proper address when searched.
Is there some search algorithm changed.
Is there a way to get back the previous implementation.
There is a need to include a platform specific apikey parameter due to restrictions on IOS devices, where it is required that the apikey is set to be for the platform at creation.
When the search is happening it would be good to show a progress indicator.
Please add posibility to get info about geolocation. Thank you.
flutter_google_places ^0.3.0 requires http ^0.13.1.
I would like the flexibility to use http version 1.0.0 or above.
Can you change it to include more versions of http please.
like this:
http: '>= 0.13.1 <= 1.2.2'
Also it turns out that http 0.13.1 is affected by [https://github.com/advisories/GHSA-4rgh-jx4f-qfcq] (GHSA-4rgh-jx4f-qfcq). Can you please edit the http requirements for this package?
I'm encountering an issue with the GooglePlaceAutoCompleteTextField widget from the google_places_flutter package. Every time I type a location into the search bar and select a suggestion from the auto-suggested list, I receive an error in my console logs.
Error:
csharp
Copy code
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0 _GooglePlaceAutoCompleteTextFieldState.getPlaceDetailsFromPlaceId
google_places_flutter.dart:252
Relevant Code:
dart
Copy code
Future<Response?> getPlaceDetailsFromPlaceId(Prediction prediction) async {
var url = "https://maps.googleapis.com/maps/api/place/details/json?placeid=${prediction.placeId}&key=${widget.googleAPIKey}";
Response response = await Dio().get(url);
PlaceDetails placeDetails = PlaceDetails.fromJson(response.data);
prediction.lat = placeDetails.result!.geometry!.location!.lat.toString();
prediction.lng = placeDetails.result!.geometry!.location!.lng.toString();
widget.getPlaceDetailWithLatLng!(prediction);
}
Steps to Reproduce:
1.Type a location into the GooglePlaceAutoCompleteTextField search bar.
2.Select any location from the suggested dropdown.
3.Observe the error in the console logs.
Additional Context:
The error seems to be related to the getPlaceDetailsFromPlaceId method, specifically when trying to access properties of the placeDetails object. I've ensured that the necessary API keys and configurations are correctly set up.
Thank you in advance.
Hi, Hope your well.
I've been trying to adjust and change the predictions list overlay as it has a dark background with dark text.
Hope you can guide me on what I might be missing or a possible fix.
Thanx
Hoy can I change the language of the autocomplete address, all of them are showed in English and I need them in Spanish
Hi! I'm hoping you might be able to help me. I'd like to get access to the Address components in the Places Details but I can't seem to see where this would be available.
Per the documentation it should be under results but I don't see it in predictions. Specifically I'm looking for:
[
{ "long_name": "48", "short_name": "48", "types": ["street_number"] },
{
"long_name": "Pirrama Road",
"short_name": "Pirrama Rd",
"types": ["route"],
},
{
"long_name": "Pyrmont",
"short_name": "Pyrmont",
"types": ["locality", "political"],
},
{
"long_name": "Council of the City of Sydney",
"short_name": "Sydney",
"types": ["administrative_area_level_2", "political"],
},
{
"long_name": "New South Wales",
"short_name": "NSW",
"types": ["administrative_area_level_1", "political"],
},
{
"long_name": "Australia",
"short_name": "AU",
"types": ["country", "political"],
},
{
"long_name": "2009",
"short_name": "2009",
"types": ["postal_code"],
},
],
Thanks!
As your library is supposed to be web compatible on pub.dev, I'm surprise to have a dio error when I try my app in any browser.
On my mobiles, prediction works fine but on any browser I have this error :
Error: DioError [DioErrorType.response]: XMLHttpRequest error.
Source stack:
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 942:28 get current
packages/dio/src/dio_mixin.dart 488:35 fetch
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/dio/src/dio_mixin.dart 487:31 fetch
packages/dio/src/dio_mixin.dart 483:12 request
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/dio/src/dio_mixin.dart 453:33 request
packages/dio/src/dio_mixin.dart 61:12 get
packages/google_places_flutter/google_places_flutter.dart 87:34 getLocation
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/google_places_flutter/google_places_flutter.dart 66:14 getLocation
packages/google_places_flutter/google_places_flutter.dart 120:5 textChanged
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/google_places_flutter/google_places_flutter.dart 119:14 textChanged
dart-sdk/lib/async/zone.dart 1594:10 runUnaryGuarded
dart-sdk/lib/async/stream_impl.dart 339:11 [_sendData]
dart-sdk/lib/async/stream_impl.dart 271:7 [_add]
dart-sdk/lib/async/stream_impl.dart 1044:46 addSync
packages/rxdart/src/utils/forwarding_stream.dart 130:35 add
packages/rxdart/src/transformers/backpressure/backpressure.dart 214:13 resolveWindowEnd
packages/rxdart/src/transformers/backpressure/backpressure.dart 155:27
dart-sdk/lib/async/zone.dart 1582:10 runGuarded
dart-sdk/lib/async/stream_impl.dart 392:13 sendDone
dart-sdk/lib/async/stream_impl.dart 402:7 [_sendDone]
dart-sdk/lib/async/stream_impl.dart 291:7 [_close]
dart-sdk/lib/async/stream_pipe.dart 311:13 [_handleData]
dart-sdk/lib/async/stream_pipe.dart 153:13 [_handleData]
dart-sdk/lib/async/zone.dart 1594:10 runUnaryGuarded
dart-sdk/lib/async/stream_impl.dart 339:11 [_sendData]
dart-sdk/lib/async/stream_impl.dart 271:7 [_add]
dart-sdk/lib/async/stream_controller.dart 784:19 [_sendData]
dart-sdk/lib/async/stream_controller.dart 658:7 [_add]
dart-sdk/lib/async/stream_controller.dart 606:5 add
packages/rxdart/src/streams/timer.dart 51:22
dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 48:19 internalCallback
dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:49 throw
packages/dio/src/dio_mixin.dart 643:7
dart-sdk/lib/async/zone.dart 1666:54 runBinary
dart-sdk/lib/async/future_impl.dart 168:22 handleError
dart-sdk/lib/async/future_impl.dart 849:46 handleError
dart-sdk/lib/async/future_impl.dart 870:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 646:5 [_completeError]
dart-sdk/lib/async/future_impl.dart 57:12 [_completeError]
dart-sdk/lib/async/future_impl.dart 24:5 completeError
dart-sdk/lib/async/future.dart 620:44 onError
dart-sdk/lib/async/zone.dart 1666:54 runBinary
dart-sdk/lib/async/future_impl.dart 168:22 handleError
dart-sdk/lib/async/future_impl.dart 849:46 handleError
dart-sdk/lib/async/future_impl.dart 870:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 646:5 [_completeError]
dart-sdk/lib/async/future_impl.dart 736:7 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15
Any idea ?
Thanks
../../../.pub-cache/hosted/pub.dev/google_places_flutter-2.0.6/lib/DioErrorHandler.dart:18:25: Error: Member not found: 'connectTimeout'.
case DioErrorType.connectTimeout:
^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dev/google_places_flutter-2.0.6/lib/DioErrorHandler.dart:21:25: Error: Member not found: 'other'.
case DioErrorType.other:
^^^^^
../../../.pub-cache/hosted/pub.dev/google_places_flutter-2.0.6/lib/DioErrorHandler.dart:33:25: Error: Member not found: 'response'.
case DioErrorType.response:
^^^^^^^^
Target kernel_snapshot failed: Exception
This error was found running with dio version 5.4.0
Please help fix it.
If I remove restriction from Api key it worked but with restricted api keys it says Invalid api key
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.