fix issue of navigation

merge-requests/558/head
Fatimah Alshammari 4 years ago
parent c84d1cadad
commit 1b9e3b75bd

@ -8,6 +8,7 @@ import 'package:url_launcher/url_launcher.dart';
import 'avatar/large_avatar.dart';
import 'my_rich_text.dart';
import 'dart:io' show Platform;
class HospitalLocation extends StatelessWidget {
final GetHMGLocationsModel location;
@ -74,7 +75,9 @@ class HospitalLocation extends StatelessWidget {
Column(
children: [
contactButton(Icons.location_on, TranslationBase.of(context).locationa, () {
MapsLauncher.launchCoordinates(double.parse(location.latitude), double.parse(location.longitude), location.locationName);
// MapsLauncher.launchCoordinates(double.parse(location.latitude), double.parse(location.longitude), location.locationName);
// launchMap( double.parse(location.latitude), double.parse(location.longitude));
navigateTo(double.parse(location.latitude), double.parse(location.longitude));
}),
SizedBox(height: 10),
contactButton(Icons.call, TranslationBase.of(context).callNow, () {
@ -107,4 +110,39 @@ class HospitalLocation extends StatelessWidget {
),
);
}
static void navigateTo(double latitude, double longitude) async {
var uri = Uri.parse("google.navigation:q=$latitude,$longitude&mode=d");
if (await canLaunch(uri.toString())) {
await launch(uri.toString());
} else {
throw 'Could not launch ${uri.toString()}';
}
}
// launchMap(latitude, longitude) async {
// var url = '';
// var urlAppleMaps = '';
// if (Platform.isAndroid) {
// url = "https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}";
// } else {
// urlAppleMaps = 'https://maps.apple.com/?q=$latitude,$longitude';
// url = "comgooglemaps://?saddr=&daddr=$latitude,$longitude&directionsmode=driving";
// if (await canLaunch(url)) {
// await launch(url);
// } else {
// throw 'Could not launch $url';
// }
// }
//
// if (await canLaunch(url)) {
// await launch(url);
// } else if (await canLaunch(urlAppleMaps)) {
// await launch(urlAppleMaps);
// } else {
// throw 'Could not launch $url';
// }
// }
}

Loading…
Cancel
Save