I got this code from Chat GPT, and I already asking many times to Chat GPT why is it error, but it doesnt help at all, and then I tried using the URL Launcher logic from the internet, and it still doesnt work, so I comeback using the code from chat gpt. Anyway here is the code :
void _launchWhatsApp() async {
final Uri url =
Uri.parse("https://www.youtube.com");
if (await canLaunchUrl(url)) {
await launchUrl(
url,
mode: LaunchMode
.externalApplication,
);
} else {
throw 'Could not launch $url';
}
}
And I call it in here
floatingActionButton: DraggableFab(
child: FloatingActionButton(
onPressed: _launchWhatsApp,
tooltip: 'Compose Message',
backgroundColor: const Color(0xFF1F2348),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0),
side: const BorderSide(
color: Colors.white,
width: 2.0,
),
),
child: const Icon(
Icons.headphones_rounded,
color: Colors.white,
),
)),
And YES I already do the pubspec and import it, and also already do the android/IOS permission for Internet.
Please Help me solve this
Just add this block of code inside AndroidManifest.xml inside quaries
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>