launchFacebookApp function
Implementation
Future launchFacebookApp(String? pageId, String fallbackUrl,
{String? type}) async {
if (pageId == null) {
launchExternalUrl(fallbackUrl);
return;
}
String fbProtocolUrl;
///on Android,
if (Platform.isAndroid) {
if (type != null) {
fbProtocolUrl = 'fb://$type/$pageId';
} else {
fbProtocolUrl = 'fb://page/$pageId';
}
} else {
fbProtocolUrl = 'fb://profile/$pageId';
}
try {
bool result = await launchUrlString(
fbProtocolUrl,
mode: LaunchMode.externalApplication,
);
if (!result) {
throw "Unable to launch Facebook app";
}
} catch (e) {
launchUrlString(
fallbackUrl,
mode: LaunchMode.externalApplication,
);
}
}