Code Monkey home page Code Monkey logo

Comments (7)

sami79031 avatar sami79031 commented on June 26, 2024 2

That worked for me. Thanks!

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

from flutter_google_places.

ziagit avatar ziagit commented on June 26, 2024

please fix this issue

from flutter_google_places.

Hosam11 avatar Hosam11 commented on June 26, 2024

same issue

from flutter_google_places.

juliansteenbakker avatar juliansteenbakker commented on June 26, 2024

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

from flutter_google_places.

fefeswa avatar fefeswa commented on June 26, 2024

https://github.com/fluttercommunity/flutter_google_places
I copied and pasted the code and it keeps giving me this message

I am a beginner in both formats but I have not found more information thanks
I have entered my key if you enter a letter it works perfectly but if you don't enter it, an error appears

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following _CastError was thrown while finalizing the widget tree:
Null check operator used on a null value
PlacesAutocompleteState.dispose (package:flutter_google_places/src/flutter_google_places.dart:467:14)

from flutter_google_places.

tariqali786 avatar tariqali786 commented on June 26, 2024

In flutter_google_places.dart main class it add listener in initState()
Timer? _debounce;

@OverRide
void initState() {
super.initState();
_queryTextController!.addListener(_onQueryChange); // added listener
}

in the listener it initialized the _debounce.

void _onQueryChange() {
if (_debounce?.isActive ?? false) _debounce!.cancel();
_debounce = Timer(Duration(milliseconds: widget.debounce), () {
if (!_queryBehavior.isClosed) {
_queryBehavior.add(_queryTextController!.text);
}
});
}
in dispose method it cancels the _debounce with ! operator .
@OverRide
void dispose() {
super.dispose();

_debounce!.cancel();

}

So when we back button pressed without entering text add listener not called and _debounce is not initialized and on dispose we cancel the debounce with ! operator which throws the error because it is not initialized.

So change the _debounce!.cancel() to _debounce?.cancel() will solve the error.

from flutter_google_places.

andrewpurves8 avatar andrewpurves8 commented on June 26, 2024

In flutter_google_places.dart main class it add listener in initState() Timer? _debounce;

@OverRide void initState() { super.initState(); _queryTextController!.addListener(_onQueryChange); // added listener }

in the listener it initialized the _debounce.

void _onQueryChange() { if (_debounce?.isActive ?? false) _debounce!.cancel(); _debounce = Timer(Duration(milliseconds: widget.debounce), () { if (!_queryBehavior.isClosed) { _queryBehavior.add(_queryTextController!.text); } }); } in dispose method it cancels the _debounce with ! operator . @OverRide void dispose() { super.dispose();

_debounce!.cancel();

}

So when we back button pressed without entering text add listener not called and _debounce is not initialized and on dispose we cancel the debounce with ! operator which throws the error because it is not initialized.

So change the _debounce!.cancel() to _debounce?.cancel() will solve the error.

I'm having the same issue, and manually changing _debounce!.cancel() to _debounce?.cancel() worked for me too. Would be great to have this included in a release.

from flutter_google_places.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.