opening a link in flutter app
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/link.dart';
import 'package:url_launcher/url_launcher.dart';
final Uri _url = Uri.parse(
'https://ia803101.us.archive.org/33/items/Misbahi_Library_Book_No__466__/Minhajul%20Arabia%20Arbi%201.pdf');
class Part1 extends StatelessWidget {
const Part1({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
iconTheme: const IconThemeData(color: Colors.white),
backgroundColor: Colors.deepPurpleAccent,
title: const Text(
'Minhaj_Ul_Arabiya_1',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
),
body: Center(
child: Link(
target: LinkTarget.defaultTarget,
uri: Uri.parse(
"https://www.blogger.com/blog/posts/5013151904575672576?hl=en-GB&tab=jj"),
builder: (context, followLink) => ElevatedButton(
onPressed: followLink, child: const Text("open page"))),
));
}
}
Future<void> _launchUrl() async {
if (!await launchUrl(_url)) {
throw Exception('Could not launch $_url');
}
}
Comments
Post a Comment