fluttercommunity/flutter_google_places

Unhandled Exception: NoSuchMethodError: The getter 'isNotEmpty' was called on null.

mostafaAbdelazim opened this issue · 2 comments

Getting this expectation when trying to type a place name, seems like I'm getting the param 'types' as a null value thus can't do types.isNotEmpty
I'm using
flutter_google_places: ^0.2.8
google_maps_webservice: ^0.0.20-nullsafety.2

here's the full expectation:
E/flutter (12084): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: NoSuchMethodError: The getter 'isNotEmpty' was called on null.
E/flutter (12084): Receiver: null
E/flutter (12084): Tried calling: isNotEmpty
E/flutter (12084): Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
E/flutter (12084): GoogleMapsPlaces.buildAutocompleteUrl (package:google_maps_webservice/src/places.dart:416:15)
E/flutter (12084): GoogleMapsPlaces.autocomplete (package:google_maps_webservice/src/places.dart:158:17)
E/flutter (12084): PlacesAutocompleteState.doSearch (package:flutter_google_places/src/flutter_google_places.dart:421:33)
E/flutter (12084): _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (12084): _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (12084): _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (12084): _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (12084): _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (12084): _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:378:25)
E/flutter (12084): _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
E/flutter (12084): _StartWithStreamSink.add (package:rxdart/src/transformers/start_with.dart:15:10)
E/flutter (12084): forwardStream... (package:rxdart/src/utils/forwarding_stream.dart:31:49)
E/flutter (12084): forwardStream.runCatching (package:rxdart/src/utils/forwarding_stream.dart:21:12)
E/flutter (12084): forwardStream.. (package:rxdart/src/utils/forwarding_stream.dart:31:28)
E/flutter (12084): _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (12084): _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (12084): _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (12084): _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (12084): _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (12084): _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
E/flutter (12084): _PendingEvents.schedule. (dart:async/stream_impl.dart:663:7)
E/flutter (12084): _rootRun (dart:async/zone.dart:1346:47)
E/flutter (12084): _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (12084): _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (12084): _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23)
E/flutter (12084): _rootRun (dart:async/zone.dart:1354:13)
E/flutter (12084): _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (12084): _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (12084): _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1202:23)
E/flutter (12084): _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (12084): _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter (12084):
W/istings.androi(12084): Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (greylist,core-platform-api, linking, allowed)

Flutter doctor output:

doctor --verbose
[√] Flutter (Channel stable, 2.0.2, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
• Flutter version 2.0.2 at C:\src\flutter
• Framework revision 8962f6dc68 (5 days ago), 2021-03-11 13:22:20 -0800
• Engine revision 5d8bf811b3
• Dart version 2.12.1

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\sasa_\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.43.0)
• VS Code at C:\Users\sasa_\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.82
• Edge (web) • edge • web-javascript • Microsoft Edge 89.0.774.54

• No issues found!
Process finished with exit code 0

Because this package is not null-safety, I have migrated it to NNBD and updated dependencies to latest version. Trying workaround https://github.com/hoc081098/flutter_google_places:

dependency_overrides:
  flutter_google_places:
    git:
      url: https://github.com/hoc081098/flutter_google_places.git
      ref: 7b6c2aa2053131142c0e48639823d24f312d00c1

Thanks @hoc081098 for the quick reply, works like a charm