import 'package:url_launcher/url_launcher.dart';
class MapsUtils {
MapsUtils._();
//latitude longitude
static Future<void> openMapWithPosition(
double latitude, double longitude) async {
String googleMapUrl =
"https://www.google.com/maps/search/?api=1&query=$latitude,$longitude";
if (await canLaunchUrl(googleMapUrl)) {
await launchUrl(googleMapUrl);
} else {
throw "Could not open the map.";
}
}
//text address
static Future<void> openMapWithAddress(String fullAddress) async {
String query = Uri.encodeComponent(fullAddress);
String googleMapUrl =
"https://www.google.com/maps/search/?api=1&query=$query";
if (await canLaunchUrl(googleMapUrl)) {
await launchUrl(googleMapUrl);
} else {
throw "Could not open the map.";
}
}
}
The argument type 'String' can't be assigned to the parameter type
I am on VS Code and once I finish writing that code this is the error(s) I am getting. Thank you!
The small mistake you've did is stored url as a String and passing that to LaunchUrl. The following changes you've to do...