flutter_google_places icon indicating copy to clipboard operation
flutter_google_places copied to clipboard

Not working

Open bksuser opened this issue 3 years ago • 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)

bksuser avatar Apr 20 '21 08:04 bksuser

Same issue

saurabhunify avatar Apr 21 '21 06:04 saurabhunify

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")] );

in3mo avatar Apr 22 '21 12:04 in3mo

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.

hoc081098 avatar May 09 '21 15:05 hoc081098

Same problem. Is anybody even working on this?

hdavidmb avatar May 09 '21 22:05 hdavidmb

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.

hdavidmb avatar May 09 '21 22:05 hdavidmb

@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. 🙏🏽

hdavidmb avatar May 09 '21 23:05 hdavidmb

@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 :))

hoc081098 avatar May 10 '21 01:05 hoc081098

Not working

bksuser avatar May 10 '21 06:05 bksuser

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

vanshkapoor avatar Jun 18 '21 17:06 vanshkapoor

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")] );

JagadishaIncture avatar Jul 28 '21 04:07 JagadishaIncture

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

abdulrehmank7 avatar Aug 26 '21 07:08 abdulrehmank7

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?

juliansteenbakker avatar Nov 19 '21 14:11 juliansteenbakker

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

sockogamez avatar Jan 08 '22 23:01 sockogamez

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 !! !!

victormanuelfrancodev avatar Jan 24 '22 11:01 victormanuelfrancodev

I fixed this error below.

https://youtu.be/ZDVhfIesqBg

Jigneshiosdeveloper avatar Feb 16 '22 18:02 Jigneshiosdeveloper

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

juliansteenbakker avatar Mar 15 '22 20:03 juliansteenbakker

Is this going to be pushed to pub.dev?

ryanlangton avatar Jul 18 '22 11:07 ryanlangton