Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: type '_Map<String, dynamic>' is not a subtype of type 'GeoPoint' #35

Open
Lsinkololwe opened this issue Aug 20, 2023 · 4 comments

Comments

@Lsinkololwe
Copy link

Team i'm encountering the below error coming from the collection .dart file.

E/flutter ( 9784): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_Map<String, dynamic>' is not a subtype of type 'GeoPoint'
E/flutter ( 9784): #0 GeoFireCollectionRef._buildQueryStream.. (package:geoflutterfire2/src/collection.dart:124:24)

The code in the library on line 124 is

final GeoPoint geoPoint = geoPointField['geopoint'];

@monika-with-a-k
Copy link

I'm encountering an issue with the same line of code, in collection.dart on line 124
final GeoPoint geoPoint = geoPointField['geopoint'];

However I get the error

flutter: type 'Null' is not a subtype of type 'GeoPoint'
flutter: 
#0      GeoFireCollectionRef._buildQueryStream.<anonymous closure>.<anonymous closure> (package:geoflutterfire2/src/collection.dart:124:24)
#1      MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)
#2      ListIterator.moveNext (dart:_internal/iterable.dart:354:26)
#3      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#4      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#5      new List.of (dart:core-patch/array_patch.dart:39:18)
#6      ListIterable.toList (dart:_internal/iterable.dart:224:7)
#7      GeoFireCollectionRef._buildQueryStream.<anonymous closure> (package:geoflutterfire2/src/collection.dart:137:24)
#8      _MapStream._handleData (dart:async/stream_pipe.dart:213:31)
#9      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#10     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#11     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:33<…>

It only seems to be an issue on iOS for me, same code works fine on Android.
Any idea what this could be?

@briteira
Copy link

I'm using v2.3.15 and it's still happening.

After a long time, I discovered that the problem was the data type in the database.

I had something like this:
image

And I changed it to this:
image

from "map" to "geopoint".

It could be resolved by changing the line you mentioned from:

final GeoPoint geoPoint = geoPointField['geopoint'];

To:

final GeoPoint geoPoint = geoPointField['geopoint'] as GeoPoint;

I hope this can be like this in the next version.

@briteira
Copy link

@monika-with-a-k If you have a null field, you should change it to a "geopoint", or ignore the records where yourField is null in your database query

@monika-with-a-k
Copy link

It's solved now. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants