share_pdf 1.0.1
share_pdf: ^1.0.1 copied to clipboard
A new Flutter package where you can give a pdf url from API, web and you can share a pdf file in any media, not just an url, it will be shared as an pdf file
import 'package:flutter/material.dart';
import 'package:share_pdf/share_pdf.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
sharePDF() async {
SharePDF sharePDF = SharePDF(
url: "https://pdfobject.com/pdf/sample.pdf",
subject: "Subject Line goes here",
);
await sharePDF.downloadAndShare();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'URL:',
),
Text(
'https://pdfobject.com/pdf/sample.pdf',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: sharePDF,
tooltip: 'Share',
child: const Icon(Icons.share),
),
);
}
}