123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import 'dart:io';
- import 'package:compdfkit_flutter/cpdf_configuration.dart';
- import 'package:compdfkit_flutter/widgets/cpdf_reader_widget.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_gen/gen_l10n/app_localizations.dart';
- import '../../utils/file_util.dart';
- class PDFDocumentPage extends StatefulWidget {
- const PDFDocumentPage({super.key});
- @override
- State<PDFDocumentPage> createState() => _PDFDocumentPageState();
- }
- class _PDFDocumentPageState extends State<PDFDocumentPage> {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(title: const Text('CPDFReaderWidget'),),
- body: SafeArea(
- child: Column(
- children: [
- Expanded(
- child: FutureBuilder(
- future: getPDFPath(),
- builder: (context, snapShot) {
- if (snapShot.connectionState == ConnectionState.done &&
- snapShot.hasData) {
- String document = snapShot.data!;
- return CPDFReaderWidget(
- document: document,
- configuration: CPDFConfiguration());
- } else {
- return Center(
- child: Column(
- children: [
- const CircularProgressIndicator(),
- Text(AppLocalizations.of(context)!.loading)
- ],
- ),
- );
- }
- }))
- ],
- )));
- }
- Future<String> getPDFPath() async {
- File document = await extractAsset(context, 'pdfs/PDF_Document.pdf');
- return document.path;
- }
- }
|