Skip to content

Commit

Permalink
Merge pull request #28 from AlessioLuciani/dev
Browse files Browse the repository at this point in the history
v0.5.0
  • Loading branch information
AlessioLuciani committed Mar 15, 2021
2 parents 225e478 + 8b739ae commit d669327
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 221 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0

* Dart's sound null safety is now supported.

## 0.4.0

* The PDFBoxResourceLoader is now used on Android to load PDF documents much faster than before. The fast initialization (i.e. *fastInit*) option has therefore been removed.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Add this to your package's `pubspec.yaml` file:

```yaml
dependencies:
pdf_text: ^0.4.0
pdf_text: ^0.5.0
```
## Usage
Expand Down Expand Up @@ -125,6 +125,7 @@ allows you not to waste time loading text that you will probably not use. When y
class PDFDoc {
int length; // Number of pages of the document
List<PDFPage> pages; // Pages of the document
PDFDocInfo info; // Info of the document
Future<String> text; // Text of the document
}
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ SPEC CHECKSUMS:
DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
pdf_text: 850e21d1a62672674099a07818c95a3f55030c81
SDWebImage: 9169792e9eec3e45bba2a0c02f74bf8bd922d1ee
SwiftyGif: e466e86c660d343357ab944a819a101c4127cb40

PODFILE CHECKSUM: 3c448a1d0ade57273cab760b57b1a710ba8d268a

COCOAPODS: 1.9.3
COCOAPODS: 1.10.0
2 changes: 0 additions & 2 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/DKImagePickerController/DKImagePickerController.framework",
"${BUILT_PRODUCTS_DIR}/DKPhotoGallery/DKPhotoGallery.framework",
"${PODS_ROOT}/../Flutter/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/SwiftyGif/SwiftyGif.framework",
"${BUILT_PRODUCTS_DIR}/file_picker/file_picker.framework",
Expand All @@ -276,7 +275,6 @@
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKImagePickerController.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKPhotoGallery.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyGif.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_picker.framework",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
39 changes: 21 additions & 18 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:io';
import 'dart:math';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'dart:async';
Expand All @@ -15,7 +13,7 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {
PDFDoc _pdfDoc;
PDFDoc? _pdfDoc;
String _text = "";

bool _buttonsEnabled = true;
Expand All @@ -37,38 +35,41 @@ class _MyAppState extends State<MyApp> {
padding: EdgeInsets.all(10),
child: ListView(
children: <Widget>[
FlatButton(
TextButton(
child: Text(
"Pick PDF document",
style: TextStyle(color: Colors.white),
),
color: Colors.blueAccent,
style: TextButton.styleFrom(
padding: EdgeInsets.all(5),
backgroundColor: Colors.blueAccent),
onPressed: _pickPDFText,
padding: EdgeInsets.all(5),
),
FlatButton(
TextButton(
child: Text(
"Read random page",
style: TextStyle(color: Colors.white),
),
color: Colors.blueAccent,
style: TextButton.styleFrom(
padding: EdgeInsets.all(5),
backgroundColor: Colors.blueAccent),
onPressed: _buttonsEnabled ? _readRandomPage : () {},
padding: EdgeInsets.all(5),
),
FlatButton(
TextButton(
child: Text(
"Read whole document",
style: TextStyle(color: Colors.white),
),
color: Colors.blueAccent,
style: TextButton.styleFrom(
padding: EdgeInsets.all(5),
backgroundColor: Colors.blueAccent),
onPressed: _buttonsEnabled ? _readWholeDoc : () {},
padding: EdgeInsets.all(5),
),
Padding(
child: Text(
_pdfDoc == null
? "Pick a new PDF document and wait for it to load..."
: "PDF document loaded, ${_pdfDoc.length} pages\n",
: "PDF document loaded, ${_pdfDoc!.length} pages\n",
style: TextStyle(fontSize: 18),
textAlign: TextAlign.center,
),
Expand All @@ -91,9 +92,11 @@ class _MyAppState extends State<MyApp> {

/// Picks a new PDF document from the device
Future _pickPDFText() async {
File file = await FilePicker.getFile();
_pdfDoc = await PDFDoc.fromFile(file);
setState(() {});
var filePickerResult = await FilePicker.platform.pickFiles();
if (filePickerResult != null) {
_pdfDoc = await PDFDoc.fromPath(filePickerResult.files.single.path!);
setState(() {});
}
}

/// Reads a random page of the document
Expand All @@ -106,7 +109,7 @@ class _MyAppState extends State<MyApp> {
});

String text =
await _pdfDoc.pageAt(Random().nextInt(_pdfDoc.length) + 1).text;
await _pdfDoc!.pageAt(Random().nextInt(_pdfDoc!.length) + 1).text;

setState(() {
_text = text;
Expand All @@ -123,7 +126,7 @@ class _MyAppState extends State<MyApp> {
_buttonsEnabled = false;
});

String text = await _pdfDoc.text;
String text = await _pdfDoc!.text;

setState(() {
_text = text;
Expand Down
Loading

0 comments on commit d669327

Please sign in to comment.