Using latest version and failing for Android and iOS: url_launcher: ^6.1.5
<!-- If your app checks for SMS support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
...
static openLink(String link) async {
// https://res.cloudinary.com/recipic/image/upload/v1663798152/odvxwkkztakrpd3gva1j.pdf
final Uri url = Uri.parse(link);
if (await canLaunchUrl(url)) {
await launchUrl(url);
} else {
throw 'Could not launch $link';
}
}
It just displays a blank page throwing no errors, just:
Accessing hidden method Lsun/misc/Unsafe;->getObject
Just add this in launchUrl() :
launchUrl(url, mode: LaunchMode.externalApplication,);
and you might need to add this to your AndroidManifest.xml
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
then you should be able to open the PDF smoothly!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With