I am using the plugin url_launcher in my Flutter app. It is working fine, but it works different on Android and on iOS devices.
The used URL proposes the download of a PDF file on Android and shows the PDF on iOS.
This is the code:
_launchURL(String codigo) async {
String url = 'https://...pdftest.php?cod='+codigo;
if (await canLaunch(url)) {
await launch(url,forceWebView: true, enableJavaScript: true,enableDomStorage: true);
} else {
throw 'Could not launch $url';
}
}
Here you have the output on iOS:
On Android, the output without the parameters
forceWebView: true, enableJavaScript: true,enableDomStorage: true
the output is as follows:
Is there a way to force the PDF show on Android? Or should I download the file and then open it from the device?
You can open PDF in Google Docs Viewer to make both behave the same
http://docs.google.com/gview?embedded=true&url=<URL>
Related
I am trying to implement badger count on app launcher icon in flutter for all android based devices. I've tried flutter_app_badger and flutter_dynamic_icon as well but both of them aren't compatible with android. I wan't a unamious solution it's awesome if it works both for android or ios as well.
I am trying to find solutions but there isn't enough data present. Onesignal push notification I am using for the app provides default badge count but it's not in all devices either.
Please help me with the situation.
setLauncherNumber()async{
// set batch number
try {
print('LauncherBadge inside try');
// FlutterAppBadger.updateBadgeCount(10);
await FlutterDynamicIcon.setApplicationIconBadgeNumber(93);
print('LauncherBadge Success');
} catch (e) {
print('LauncherBadge error $e');
}
}
flutter_app_badger and flutter_dynamic_icon arent compatible with all devices
Use this package flutter_app_badger: ^1.5.0
import 'package:flutter_app_badger/flutter_app_badger.dart';
FlutterAppBadger.updateBadgeCount(1);
i want to launch google map when tap on button, nothing complicated. i found easy code also from google search. Pasting the code below for reference. i dont know it is the proper way to do.
class MapUtils {
MapUtils._();
static 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.';
}
}
}
pubspec.yaml added -> url_launcher: ^6.0.17
i called this -> MapUtils.openMap(-33.2445107, 9.1530103)
Whenever i tap on the button return error as "Unhandled Exception: MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher)"
i tried to find solution, what i tried is
Flutter clean, flutter pub get.
Close everything reopen
uninstall app from emulator device.
close emulator and restart.
total computer restart.
it is nothing related url_launcher still i add the google map api to androidmanifest and appdelegate. Enables Api.
Lot of popel are asking about the same error. May be i am missing something todo.
I have a button on screen, when you click button I need to open some folder picker.
I have searched for package, but I didn't found any package that also support Android and iOS.
Does someone knows some package who will resolve this problem, or something I could use to make solution of picking folder on iOS?
EDIT:
I found way to get directory picker functionality,I didn't test on iOS but in documentation says it works on both (Android and iOS).
String path = await FilePicker.platform.getDirectoryPath();
With this line above you get new screen to select your directory and get a path like result from that Future.
This is solved using file_picker package.
Use the package file_picker.
Easy to use:
FilePickerResult? result = await FilePicker.platform.pickFiles();
if(result != null) {
File file = File(result.files.single.path);
} else {
// Do something else...
}
I'm using Ionic 4 (4.12.0) with the PhotoViewer plugin versions:
"#ionic-native/photo-viewer": "^5.21.5",
"com-sarriaroman-photoviewer": "^1.2.4",
And the code is:
public presentImage(imgSrc): void {
this.photoViewer.show(imgSrc, '', {
share: false,
closeButton: true,
copyToReference: true
});
}
The variable imgSrc is a base64. If I remove the options, the photoViewer opens with a black screen, but with the options it's crashing the app. But as the title states, it only happens on iOS.
after read the document, base64 is just supported on android. So it is what the problem.
(1.1.4) Base64 Support on Android
I have built an app with flutter, what I am trying to do is download a document, these are jpeg, jpg or pdf files, from my REST api, and open it within the app so the user can see it,
The below piece of code is the issue, I am trying to use the openfile package in flutter, the code works perfectly on android, it opens the image automatically, but on ios, it gives the attached screen after attempting to download.
I am putting part of my code which I believe is the issue.
Code to specify the plugin parameter
if (Platform.isIOS)
directory = await getTemporaryDirectory();
else
directory = await getExternalStorageDirectory();
Code to open the file
OpenFile.open(downloadPath).then((_result) {
_closePopup();
print(_result);
}).catchError((error) {
print("Could not open file *** $error");
FileDownloader.lastError =
"Could not open file: " + error.toString();
_closePopup();
});
} else {
Any guidance on this will help.
Buttton sample I am trying to work out
IOS Behaviour with code