readpdf 0.0.3
readpdf: ^0.0.3 copied to clipboard
A plugin to read pdf files
example/lib/main.dart
import 'dart:io';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
import 'package:readpdf/readpdf.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _readpdfPlugin = Readpdf();
Future<String> getAppDirectory() async{
Directory appDocDir = await getApplicationDocumentsDirectory();
return appDocDir.path;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
//child: Text('Running on: $_platformVersion\n'),
child: MaterialButton(onPressed: (){
//_readpdfPlugin.showAlert();
_resultReadPdf();
},
color: Colors.green,
child: const Text("View PDF")
),
),
),
);
}
_resultReadPdf() async{
String path = await getAppDirectory();
debugPrint("value: $path/Beginning Flutter.pdf");
String result;
try {
result = await _readpdfPlugin.viewPdf('$path/Beginning Flutter.pdf', 'Beginning Flutter', 'Grade 9', 'en', 4);
}on PlatformException {
result = 'Failed to get information.';
}
debugPrint("Result : $result");
}
}