Open Omar-Salem opened 2 years ago
please fix this issue
same issue
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
That worked for me. Thanks!
flutter_google_places:
git:
url: https://github.com/fluttercommunity/flutter_google_places
ref: v0.3.2
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)
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.
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.
Null check operator used on a null value