Xander van Zyl
Xander van Zyl

Reputation: 165

Is it possible to share your location through flutter app

I built an app in flutter, dart to access the location of the user. I now want to share the current physical location of the user via Whatsapp, email etc but not as coordinates.

I have tried geolocation as well as location but seem to only manage to get the coordinates. Below is a snippet of my share button that shows me the coordinates.

_share(){ Share.share('I have arrived safely at ${_currentLocation.latitude} & ${_currentLocation.longitude}'); }

I am expecting to see a message that can be shared to anyone on my device that provides my current location. I am not receiving any error messages as i am currently only getting the coordinates as shown in the code. What can be done to share the physical location of my device?

Upvotes: 3

Views: 7108

Answers (1)

Xander van Zyl
Xander van Zyl

Reputation: 165

I have figured out that the only way to be able to share your location via a flutter app is to add the coordinates to a url string of google maps

i.e.

_share(){
    Share.share('https://www.google.com/maps/search/?api=1&query=${_currentLocation.latitude},${_currentLocation.longitude}');
  }

Upvotes: 12

Related Questions