buildYouTube function
Implementation
Widget buildYouTube(String id) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.play_circle_fill, size: 80, color: Colors.red),
const SizedBox(height: 20),
ElevatedButton.icon(
icon: const Icon(Icons.open_in_new),
label: const Text('Otwórz video na YouTube'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
),
onPressed: () async {
final url = Uri.parse('https://www.youtube.com/watch?v=$id');
if (await canLaunchUrl(url)) {
await launchUrl(url, mode: LaunchMode.externalApplication);
}
},
),
],
),
);
}