61 lines
1.5 KiB
Dart
61 lines
1.5 KiB
Dart
part of 'index.dart';
|
|
|
|
class DocumentViewScreen extends StatefulScreen {
|
|
const DocumentViewScreen({
|
|
super.key,
|
|
required this.document,
|
|
});
|
|
|
|
final Document document;
|
|
|
|
@override
|
|
State<DocumentViewScreen> createState() => _DocumentViewScreenState();
|
|
}
|
|
|
|
class _DocumentViewScreenState extends State<DocumentViewScreen> {
|
|
final PDFViewerKey _viewerKey = PDFViewerKey();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Uri url = Uri.parse(
|
|
'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf');
|
|
|
|
void onPressed() async {
|
|
final response = await http.get(url);
|
|
if (response.statusCode == 200) {
|
|
final XFile xfile = XFile.fromData(response.bodyBytes,
|
|
name:
|
|
'${widget.document.description}_${widget.document.category.title}.pdf',
|
|
mimeType: 'application/pdf');
|
|
await Share.shareXFiles([xfile], text: 'Confira este PDF!');
|
|
} else {
|
|
print('Erro ao baixar o arquivo: ${response.statusCode}');
|
|
}
|
|
}
|
|
|
|
return Stack(
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.all(10),
|
|
child: FREViewerPDF(
|
|
search: _viewerKey,
|
|
src: url.toString(),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 10,
|
|
right: 10,
|
|
child: IconButton(
|
|
icon: Icon(
|
|
Icons.share,
|
|
color: Colors.black,
|
|
),
|
|
color: Colors.black,
|
|
onPressed: onPressed,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|