Navigate to GoogleMap and MapKit in Flutter without Dev Dependency - flutter

How to Navigate Latitude & Longitude to GoogleMap and MapKit in Flutter without using Dependency.
Am using Dependency this Dependency - url_launcher: ^6.1.4
static Future<void> openMap(double latitude, double longitude) async {
String iosUrl = 'https://maps.apple.com/?q=$latitude,$longitude';
if (GetPlatform.isAndroid) {
String googleUrl ='https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';
if (await canLaunch(googleUrl)) {
await launch(googleUrl);
} else {
throw 'Could not launch $googleUrl';
}
}else{
if (await canLaunch(iosUrl)) {
await launch(iosUrl);
} else {
throw 'Could not open the map.';
}
}
}
This above code is Working Fine and Running properly. But I need Solution without Dependency

Related

when on press on ElevatedButton I want open Routing applications. Flutter

I get current location and my destination in app, when on press on ElevatedButton I want open Routing applications like google maps or Waze in user mobile.
ElevatedButton(
onPressed: () {
},
),
how can I do that?
use this package and do it like this:
Future<void> openMap(double latitude, double longitude) async {
String googleUrl = 'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';
if (await canLaunch(googleUrl)) {
await launch(googleUrl);
} else {
throw 'Could not open the map.';
}
}
Its better to use this package like this:
Future<void> openMap(double latitude, double longitude) async {
String googleUrl = 'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';
var _params;
Uri googleUri = Uri.parse(googleUrl).replace(queryParameters: _params);
if (await canLaunchUrl(googleUri)) {
await launchUrl(googleUri);
} else {
throw 'Could not open the map.';
}
}

Launch link in flutter

i would like to launch custom dynamic links..
i have getter which load string text from database, this string text is user input with them IG username
bio is IG username, exsample #instagram
String getBio(String bio) {
if (widget.isMyProfile) {
return bio;
} else if (bio == "") {
return "";
} else {
return bio;
}
}
i want to have static link "**https://instagram.com/**;" where end of link will be dynamic instagram user name
example: 'https://instagram.com/instagram';
_launchURLIG() async {
const url = 'https://instagram.com/';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
=====
something like this. https://instagram.com' + getBio
_launchURLIG() async {
const url = 'https://instagram.com' + getBio ;
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
You should past profile as a parameter to your function
_launchURLIG(String userId) async {
String url = 'https://instagram.com/' + userId ;
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
Maybe you need this package to run link:
https://pub.dev/packages/url_launcher

storage_path flutter plugin returning IOS version(15.2) in imagesPath

Plug-in functions return version in imagepath.
same behaviour in all these functions getImagesPath() ,getVideoPath(),getAudioPath(),getFilePath().
Plug in: https://pub.dev/packages/storage_path , storage_path: ^0.2.0
Future<void> getImagesPath() async {
String imagespath = "";
try {
**imagespath = await StoragePath.imagesPath;** // return IOS Version (Example: Ios 15.2)
var response = jsonDecode(imagespath);
print(response);
var imageList = response as List;
List<FileModel> list = imageList.map<FileModel>((json) => FileModel.fromJson(json)).toList();
setState(() {
imagePath = list[11].files[0];
});
} on PlatformException {
imagespath = 'Failed to get path';
}
return imagespath;
}
I got it. Actually, I missed reading the Readme file. This plug-in is only available with android.
ONLY FOR ANDROID

How to launch other android apps using the flutter app

I have used the following method as specified in the documentation.
Future<void> launchUniversalLink(String url) async {
if (await canLaunch(url)) {
final bool nativeAppLaunchSuccess = await launch(url, forceSafariVC: false, universalLinksOnly: true);
print(nativeAppLaunchSuccess);
}else {
print('launch not successfull');
}
}
if I give URL = 'https://www.WhatsApp.com'
print(nativeAppLaunchSuccess); output ==> true
but still the app launches in the browser.
can anyone help me with this problem
Oh I'm sorry. This is my mistake.
Please use 'device_apps' flutter package and usage is below.
And here is a how to know app package name.
https://www.techmesto.com/find-android-app-package-name/
In ios, you know other app's custom Url schema that officially opened.
But usually we can not know that url.
So below ios code is executed, it will open appstore page and need to push 'open' button.
if (Platform.isAndroid) {
if (await DeviceApps.isAppInstalled('com.nbt.moves') ==
true) {
DeviceApps.openApp('com.nbt.moves');
}
} else {
const url =
'https://apps.apple.com/kr/app/%EC%BA%90%EC%8B%9C%EC%8A%AC%EB%9D%BC%EC%9D%B4%EB%93%9C-%EC%8A%A4%ED%85%9D%EC%97%85/id1400703652?uo=4';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}

Flutter Location package requestService() never returns

I have a function like this. Using Location package from flutter it shows the dialog to enable GPS.
Future<bool> _checkServiceStatus() async {
final Location location = Location();
bool serviceStatus = await location.serviceEnabled();
if (!serviceStatus) {
serviceStatus = await location.requestService();
print('status -> $serviceStatus');
}
return serviceStatus;
}
When its calling await location.requestService(), it is showing the dialog to enable GPS but after that it never returns the result.
Even its not executing the print() function.
What am i doing wrong here?
Any help would be very appreciated! Thanks in advance.
I had the same issue. It could be solved by upgrading your Flutter project, follow this link https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
Try this code to check wather permission enabled, service enabled than it returns true else false. Must configure "location" package related configuration in android and ios projects.
Future<bool> checkServiceStatus() async {
final Location location = Location();
final locationPermission = await location.hasPermission();
if (locationPermission == PermissionStatus.granted) {
final locationServiceEnabled = await location.serviceEnabled();
if (locationServiceEnabled == true) {
return true;
} else {
final requestServiceStatus = await location.requestService();
if (requestServiceStatus == true) {
return true;
} else {
BotToast.showSimpleNotification(
title: "Enable GPS to allow this feature");
return false;
}
}
} else {
BotToast.showSimpleNotification(title: "Required location permission to allow this feature");
return false;
}
}