fluttercommunity/flutter_google_places

Not working

bksuser opened this issue ยท 17 comments

[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: Null check operator used on a null value
#0 PlacesAutocompleteState.doSearch (package:flutter_google_places/src/flutter_google_places.dart:436:28)
#1 _rootRunUnary (dart:async/zone.dart:1362:47)
#2 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#3 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#4 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#5 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#6 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:378:25)
#7 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
#8 _StartWithStreamSink.add (package:rxdart/src/transformers/start_with.dart:15:10)
#9 forwardStream... (package:rxdart/src/utils/forwarding_stream.dart:31:49)

Same issue

in3mo commented

You have to send all the parameters of the function:

Prediction p = await PlacesAutocomplete.show(
offset: 0,
radius: 1000,
types: [],
strictbounds: false,
region: "ar",
context: context,
apiKey: kGoogleApiKey,
mode: Mode.overlay, // Mode.fullscreen
language: "es",
components: [Component(Component.country, "ar")]
);

Trying it: https://pub.dev/packages/flutter_google_places_hoc081098

  • Migrated to null-safety.
  • Updated dependencies to latest release.
  • Refactoring by using RxDart for more power.
  • Fixed many issues.
  • Applied flutter_lints.
  • Refactored example, migrated to Android v2 embedding.

Same problem. Is anybody even working on this?

Complementing @in3mo answer. The conflicting parameters are types, strictbounds and components .

This parameters are marked as optional in the show() method but later they are being checked as non-null (the "!" checker) in flutter_google_places-0.3.0/lib/src/flutter_google_places.dart on the doSearch() method (line 429):

final res = await _places!.autocomplete(
        value,
        offset: widget.offset,
        location: widget.location,
        radius: widget.radius,
        language: widget.language,
        sessionToken: widget.sessionToken,
        types: widget.types!,  //!<---------------------- Here
        components: widget.components!, //!<------------- Here
        strictbounds: widget.strictbounds!, //!<---------- Here
        region: widget.region,
      );

The problem is that specifying components will limit the search results to the countries you pass on those components parameter. So you should pass an empty list on components parameter in order to let the results to be from any country.

@hoc081098 I'm trying your package and it's working great on version ^1.0.0-nullsafety.1

I had to downgrade because the last version (^1.0.0-nullsafety.2) depends on rxdart ^0.27.0 and has a conflict with other package I'm using which last version depends on rxdart ^0.26.0. Is it any way to make flutter_google_places_hoc081098 depend on rxdart <=0.27.0?

And I'm also having another issue (as well as in flutter_google_places). Importing the main package with import 'package:flutter_google_places_hoc081098/flutter_google_places_hoc081098.dart'; doesn't expose the Prediction class and my dart file doesn't recognize it. So I had to import places.dart with import 'package:google_maps_webservice/src/places.dart';

But anyways, thanks for your package. ๐Ÿ™๐Ÿฝ

@hoc081098 I'm trying your package and it's working great on version ^1.0.0-nullsafety.1

I had to downgrade because the last version (^1.0.0-nullsafety.2) depends on rxdart ^0.27.0 and has a conflict with other package I'm using which last version depends on rxdart ^0.26.0. Is it any way to make flutter_google_places_hoc081098 depend on rxdart <=0.27.0?

And I'm also having another issue (as well as in flutter_google_places). Importing the main package with import 'package:flutter_google_places_hoc081098/flutter_google_places_hoc081098.dart'; doesn't expose the Prediction class and my dart file doesn't recognize it. So I had to import places.dart with import 'package:google_maps_webservice/src/places.dart';

But anyways, thanks for your package. ๐Ÿ™๐Ÿฝ

If you're using rxdart: 0.26.0, just use 1.0.0-nullsafety.1 :))

Not working

Got this issue when upgraded to null safety.
Solved it by changing type to this
image

For Inidan Users

Prediction? p = await PlacesAutocomplete.show( offset: 0, radius: 1000, types: [], strictbounds: false, region: "in", context: context, apiKey: Constants.API_KEY, mode: Mode.overlay, // Mode.fullscreen language: "en", onError: (value) { Utils.displayToast(context, value.errorMessage!); }, components: [Component(Component.country, "in")] );

Instead of using this plugin, I created a utility class for Google places auto complete : https://arkapp.medium.com/flutter-and-google-map-for-beginners-part-1-fdba4ab22148

I have just became maintainer of this package so I'm planning on getting it back on track and up to date with the latest version of Flutter.

@hoc081098 I see you have lot's of improvements in your fork. Do you think it it's possible to backport new features into this original package?

SOLVED!!!

first make this :
flutter channel stable
flutter upgrade
flutter pub cache repair
flutter clean

then :
is working whitout changes .. just put this parameters in the section like this :

Prediction p = await  PlacesAutocomplete.show(
    context: context, // required
    apiKey: Enviroment.API_KEY_MAPS, // required
    mode: Mode.overlay, // required any
    language: 'es', // required any
    region:'mx',  // any 
    strictbounds: true, //required
    radius: 1000, // any
    offset: 0, // required 
    types: [], //required
    startText: '',
    components: [lugares.Component(lugares.Component.country, "mx")], // required any
    location: lugares.Location( lat:_position.latitude,lng: _position.longitude) // required any
);

Good look people.
Sin tรญtulo

Trying it: https://pub.dev/packages/flutter_google_places_hoc081098

  • Migrated to null-safety.
  • Updated dependencies to latest release.
  • Refactoring by using RxDart for more power.
  • Fixed many issues.
  • Applied flutter_lints.
  • Refactored example, migrated to Android v2 embedding.

thx !! !!

I fixed this error below.

https://youtu.be/ZDVhfIesqBg

Can you please try the following in pubspec.yaml

  flutter_google_places:
    git:
      url: https://github.com/fluttercommunity/flutter_google_places
      ref: v0.3.2

Once i have the permissions, i will upload the changes to pub.dev

Is this going to be pushed to pub.dev?