forked from yaso_meth/mih-project
add print preview page
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/mih_components/mih_layout/mih_action.dart';
|
||||
import 'package:patient_manager/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:patient_manager/mih_objects/arguments.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:printing/printing.dart';
|
||||
|
||||
class MIHPrintPreview extends StatefulWidget {
|
||||
final PrintPreviewArguments arguments;
|
||||
const MIHPrintPreview({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MIHPrintPreview> createState() => _MIHPrintPreviewState();
|
||||
}
|
||||
|
||||
class _MIHPrintPreviewState extends State<MIHPrintPreview> {
|
||||
MIHAction getActionButton() {
|
||||
return MIHAction(
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PdfPreview(
|
||||
pdfFileName: widget.arguments.fileName,
|
||||
initialPageFormat: PdfPageFormat.a4,
|
||||
loadingWidget: const Mihloadingcircle(),
|
||||
actions: [getActionButton()],
|
||||
build: (format) => widget.arguments.pdfData,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user