How to share my location from flutter app to whatsapp number?
711
I solved this issue using the code below
final maps = Uri.https("google.com", "/maps/search/", { "api=1&query": "$lat,$lng" });
Author by
Sasha Kondrashov
Professional DRY practitioner and machine learning enthusiast. I'm working on creating CUI and I am proud of it. It's a language for creating UIs with a web implementation that compiles to Css, Wasm, and HTML!
Updated on December 24, 2022Comments
-
Sasha Kondrashov over 1 year
I have a function that shared data to whatsapp number, but when sending a google location it`s not working.
when printing the URL that I get at this function:
https://www.google.com/maps/search/?api=1&query=9.5191017,8.1450133
but I see that in WhatsApp look like:
https://www.google.com/maps/search/?api=1
my code :
_launchURL() async { var phonenumber = numberphone.substring(1,10); var url = 'https://wa.me/+972$phonenumber?text=$textToSend'; print(url); if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } }
my code that called the _launchURL()
onPressed: () async{ Position position = await getCurrentPosition(desiredAccuracy: LocationAccuracy.high); textToSend='https://www.google.com/maps/search/?api=1&query=${position.latitude},${position.longitude}'.toString() ; _launchURL(); }
any one can help me how to share location in whatsapp app using flutter ? Thank you
-
RaSha over 3 yearsTake a look at this link it may help you: stackoverflow.com/questions/60947937/…
-
Admin over 3 yearsIts not help , I tried that before
-
-
Shazamo Morebucks almost 3 yearsSo you then put maps.toString() as textToSend? Is it possible to have a longer message, like text: "Hey my location is: \n ${maps.toString()}"
-
Tiago Brückmann almost 3 yearsHi, I don't send it with .toString, I create a variable to send a text, like the code below: String _messageMotoBoy = "Estabelecimento: $_establishment \n\n" "Bairro: $nbHood \n" "Comp: $comp \n" "Ref: $ref \n" "Cidade: $cityUf \n\n\n" "Cobrar do Cliente: R\$ $total \n\n" "Forma de pagamento\n" "$_methodPayment" "Localização da entrega \n\n" "$waze \n\n" "$maps"; var whatsappUrl = "whatsapp://send?phone=+55${driver.phone}&text=$_messageMotoBoy";