matanshukry / flutter_google_places_sdk

Flutter plugin for google places native sdk
32 stars 68 forks source link

fix: in web implementation session token is never used during the place autocomplete #45

Open mrcsilverfox opened 1 year ago

mrcsilverfox commented 1 year ago

In web implementation session token is never used during the place autocomplete

mrcsilverfox commented 1 year ago

@AndreiMisiukevich why the install dependencies failed? Which version of flutter is needed?

matanshukry commented 1 year ago

@mrcsilverfox it's because of the flutter version the CI is using; you can ignore that.

mrcsilverfox commented 1 year ago

I also mentioned that in the comments - but the last session token should be set based on the response -which is missing here.

Also see this: #31 fro the corect usage of the tokens, which it doesn't do.

  1. If you match the web package to the mobile (missing setting the value from the response) - we'll merge.
  2. If you prefer to go ahead and impleemnt the correct behavior based on the issue - we can merge that too.

Do you think that is enough?

final prom = _svcAutoComplete!.getPlacePredictions(
      AutocompletionRequest()
        ..input = query
        ..origin = origin == null ? null : core.LatLng(origin.lat, origin.lng)
        ..types = typeFilterStr == null ? null : [typeFilterStr]
        ..componentRestrictions = (ComponentRestrictions()..country = countries)
        ..bounds = _boundsToWeb(locationBias)
        ..sessionToken = sessionToken
        ..language = _language,
      (results, status) {
        if (status == PlacesServiceStatus.OK ||
            status == PlacesServiceStatus.ZERO_RESULTS ||
            status == PlacesServiceStatus.NOT_FOUND) {
          _lastSessionToken = sessionToken;
        } else {
          log('API_ERROR: $status');
        }
      },
    );

Or we have to use the completer as used in _getDetails method?

Although I didn't understand why the session token should be set based on the response. Why can't the session token be set in the getSessionToken method?

mrcsilverfox commented 9 months ago

@matanshukry Any updates on this PR?