launchMapsApp function
Implementation
Future<void> launchMapsApp({
required String latitude,
required String longitude,
String label = '',
}) async {
if (latitude.isEmpty || longitude.isEmpty) {
return;
}
final Uri googleMapUri = Uri.parse(
'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude${label.isNotEmpty ? '($label)' : ''}',
);
if (await canLaunchUrl(googleMapUri)) {
await launchUrl(googleMapUri, mode: LaunchMode.externalApplication);
} else {
throw 'Impossible de lancer Google Maps';
}
}