Baseflow / flutter-geocoding

A Geocoding plugin for Flutter
https://baseflow.com
MIT License
134 stars 69 forks source link

[Question]: PlacemarkFromCoordinates throws an exception #231

Closed resgeza closed 2 months ago

resgeza commented 2 months ago

Please check the following before submitting a new issue.

Please select for which platform(s) you need help

Your question

I am trying to use the placemarkFromCoordinates, and it keeps throwing an exception: Unexpected null value. I have checked and the GeocodingPlatform.instance is null, I think this is the problem.

Version

3.0.0

TimHoogstrate commented 2 months ago

Dear @resgeza,

Thanks for filing this issue. Please take a look how we use the geocoding form the example app. You probably should use that to create your own code.

You probably should use something like:

placemarkFromCoordinates(latitude, longitude)
                      .then((placemarks) {
                    var output = 'No results found.';
                    if (placemarks.isNotEmpty) {
                      output = placemarks[0].toString();
                    }

                    setState(() {
                      _output = output;
                    });
                  });

Kind regards,

resgeza commented 2 months ago

Hi @TimHoogstrate ,

I still got the same error, at the line where ".then((placemarks){"

the stack trace looks like this: errors.dart:251 Uncaught (in promise) Error: Unexpected null value. at Object.throw_ [as throw] (errors.dart:251:49) at Object.nullCheck (operations.dart:528:63) at Object.placemarkFromCoordinates (geocoding.dart:31:33) at create_client_view._CreateClientViewState.new.getLocation (create_client_view.dart:48:10)

I think the GeocodingPlatform.instance is null.

Kind regards, Géza

TimHoogstrate commented 2 months ago

Dear @resgeza,

Can you try the example project, to see if there are different results?

Kind regards,

resgeza commented 2 months ago

Hi @TimHoogstrate,

I have created a new project and copied the example project, added the two dependecies in the yaml: geocoding: ^3.0.0 baseflow_plugin_template: ^2.1.2

When I click on the "Look up address" in the console I can see: Another exception was thrown: Unexpected null value.

I did a "print(GeocodingPlatform.instance);" and it traces a "null" in the console.

Kind regards, Géza

resgeza commented 2 months ago

Hi @TimHoogstrate,

I have found out the problem was that I was running the application in the Chrome, and not on the android device. On the phone it is working.

Thank you! Géza