Use Current Device Location as JSON in API call

Database & APIs

I want to display the distance between the user and a restaurant. I currently have an API set up using Buildship that does the calculation and is able to return the distance between two locations.

However, the location I provide it through Flutterflow, is static - to test the function.

I need to find out how I can convert the Device Current Location to JSON and set its value somewhere, so I can use it in the API. It is the user_location variable.

The data I provide to make it work is - and which I need from the Device current Location - is:

{   
"latitude": 55.6896348,  
"longitude": 12.4543026
}
What have you tried so far?

I have been unsuccesful in installing pubdev components. I get a lot of errors and have no experience on how to fix them. Also tried a bit of ChatGPT and other solutions I found online to convert the location into string and then JSON, but none seem to do the trick - or more likely, I don't know how to use them properly.

Did you check FlutterFlow's Documentation for this topic?
No
2