a14n / dart-google-maps

A library to use Google Maps JavaScript API v3 from Dart scripts.
Apache License 2.0
130 stars 66 forks source link

google_maps: 8.0.0 - TypeError: Cannot read properties of undefined (reading 'x') #133

Closed Rexios80 closed 4 months ago

Rexios80 commented 4 months ago
 ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
 The following JSNoSuchMethodError was thrown running a test:
 TypeError: Cannot read properties of undefined (reading 'x')

 When the exception was thrown, this was the stack:
 https://maps.googleapis.com/maps/api/js?key=redacted&libraries=geometry 363:449  fromLatLngToPoint
 packages/google_maps/src/generated/image_overlay/projection.dart 26:18                                          <fn>
 packages/google_maps_flutter_web/src/third_party/to_screen_location/to_screen_location.dart 44:42               toScreenLocation
 packages/google_maps_flutter_web/src/google_maps_controller.dart 406:9                                          getScreenCoordinate
 dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                                              runBody
 dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                                              _async
 packages/google_maps_flutter_web/src/google_maps_controller.dart 401:47                                         getScreenCoordinate
 packages/google_maps_flutter_web/src/google_maps_flutter_web.dart 163:22                                        getScreenCoordinate
 packages/google_maps_flutter/src/controller.dart 216:10                                                         getScreenCoordinate
 projection_test.dart 147:29                                                                                     <fn>
 dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50                                              <fn>
 dart-sdk/lib/async/zone.dart 1407:47                                                                            _rootRunUnary
 dart-sdk/lib/async/zone.dart 1308:19                                                                            runUnary
 dart-sdk/lib/async/future_impl.dart 163:18                                                                      handleValue
 dart-sdk/lib/async/future_impl.dart 861:44                                                                      handleValueCallback
 dart-sdk/lib/async/future_impl.dart 890:13                                                                      _propagateToListeners
 dart-sdk/lib/async/future_impl.dart 666:5                                                                       [_completeWithValue]
 dart-sdk/lib/async/future_impl.dart 736:7                                                                       <fn>
 dart-sdk/lib/async/zone.dart 1399:13                                                                            _rootRun
 dart-sdk/lib/async/zone.dart 1301:19                                                                            run
 dart-sdk/lib/async/zone.dart 1209:7                                                                             runGuarded
 dart-sdk/lib/async/zone.dart 1249:23                                                                            callback
 dart-sdk/lib/async/schedule_microtask.dart 40:11                                                                _microtaskLoop
 dart-sdk/lib/async/schedule_microtask.dart 49:5                                                                 _startMicrotaskLoop
 dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7                                              <fn>

 The test description was:
   target of map is in center of widget
 ════════════════════════════════════════════════════════════════════════════════════════════════════

I get this when running the following command in packages/google_maps_flutter/google_maps_flutter_web/example:

flutter drive -d web-server --web-port=7357 --browser-name=chrome --web-renderer=html --driver test_driver/integration_test.dart --target integration_test/projection_test.dart

This is the repo: https://github.com/Rexios80/packages_flutter

Branch: google-maps-package-web-migration

It kind of seems like the issue isn't with the function getter itself but something else. Maybe an initialization issue? But I'm not sure what because the test runs fine on the main branch. Also this is the only getter with an issue.

a14n commented 4 months ago

Not sure where this comes from but could you try 0f57b7d99ed9652a31cd60a5dd4f3c6cb6b9f31a ?

Rexios80 commented 4 months ago

You are a genius! I'm not sure why I didn't think of that since I had the exact same issue with event.trigger. It must have something to do with Dart not distinguishing between JS undefined and null.

0hsoyeop commented 4 months ago

@Rexios80 It seems like your API key is exposed in the code. It would be better to hide it.

Rexios80 commented 4 months ago

@0hsoyeop thanks for looking out but I believe that's Google's API key and it's in their repo