Skip to content

Commit d669327

Browse files
Merge pull request #28 from AlessioLuciani/dev
v0.5.0
2 parents 225e478 + 8b739ae commit d669327

File tree

18 files changed

+202
-221
lines changed

18 files changed

+202
-221
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.0
2+
3+
* Dart's sound null safety is now supported.
4+
15
## 0.4.0
26

37
* 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.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Add this to your package's `pubspec.yaml` file:
1818

1919
```yaml
2020
dependencies:
21-
pdf_text: ^0.4.0
21+
pdf_text: ^0.5.0
2222
```
2323
2424
## Usage
@@ -125,6 +125,7 @@ allows you not to waste time loading text that you will probably not use. When y
125125
class PDFDoc {
126126
int length; // Number of pages of the document
127127
List<PDFPage> pages; // Pages of the document
128+
PDFDocInfo info; // Info of the document
128129
Future<String> text; // Text of the document
129130
}
130131

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ SPEC CHECKSUMS:
7070
DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d
7171
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
7272
file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1
73-
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
73+
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
7474
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
7575
pdf_text: 850e21d1a62672674099a07818c95a3f55030c81
7676
SDWebImage: 9169792e9eec3e45bba2a0c02f74bf8bd922d1ee
7777
SwiftyGif: e466e86c660d343357ab944a819a101c4127cb40
7878

7979
PODFILE CHECKSUM: 3c448a1d0ade57273cab760b57b1a710ba8d268a
8080

81-
COCOAPODS: 1.9.3
81+
COCOAPODS: 1.10.0

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@
265265
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
266266
"${BUILT_PRODUCTS_DIR}/DKImagePickerController/DKImagePickerController.framework",
267267
"${BUILT_PRODUCTS_DIR}/DKPhotoGallery/DKPhotoGallery.framework",
268-
"${PODS_ROOT}/../Flutter/Flutter.framework",
269268
"${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
270269
"${BUILT_PRODUCTS_DIR}/SwiftyGif/SwiftyGif.framework",
271270
"${BUILT_PRODUCTS_DIR}/file_picker/file_picker.framework",
@@ -276,7 +275,6 @@
276275
outputPaths = (
277276
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKImagePickerController.framework",
278277
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKPhotoGallery.framework",
279-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
280278
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
281279
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyGif.framework",
282280
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_picker.framework",

example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

example/lib/main.dart

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import 'dart:io';
21
import 'dart:math';
3-
42
import 'package:file_picker/file_picker.dart';
53
import 'package:flutter/material.dart';
64
import 'dart:async';
@@ -15,7 +13,7 @@ class MyApp extends StatefulWidget {
1513
}
1614

1715
class _MyAppState extends State<MyApp> {
18-
PDFDoc _pdfDoc;
16+
PDFDoc? _pdfDoc;
1917
String _text = "";
2018

2119
bool _buttonsEnabled = true;
@@ -37,38 +35,41 @@ class _MyAppState extends State<MyApp> {
3735
padding: EdgeInsets.all(10),
3836
child: ListView(
3937
children: <Widget>[
40-
FlatButton(
38+
TextButton(
4139
child: Text(
4240
"Pick PDF document",
4341
style: TextStyle(color: Colors.white),
4442
),
45-
color: Colors.blueAccent,
43+
style: TextButton.styleFrom(
44+
padding: EdgeInsets.all(5),
45+
backgroundColor: Colors.blueAccent),
4646
onPressed: _pickPDFText,
47-
padding: EdgeInsets.all(5),
4847
),
49-
FlatButton(
48+
TextButton(
5049
child: Text(
5150
"Read random page",
5251
style: TextStyle(color: Colors.white),
5352
),
54-
color: Colors.blueAccent,
53+
style: TextButton.styleFrom(
54+
padding: EdgeInsets.all(5),
55+
backgroundColor: Colors.blueAccent),
5556
onPressed: _buttonsEnabled ? _readRandomPage : () {},
56-
padding: EdgeInsets.all(5),
5757
),
58-
FlatButton(
58+
TextButton(
5959
child: Text(
6060
"Read whole document",
6161
style: TextStyle(color: Colors.white),
6262
),
63-
color: Colors.blueAccent,
63+
style: TextButton.styleFrom(
64+
padding: EdgeInsets.all(5),
65+
backgroundColor: Colors.blueAccent),
6466
onPressed: _buttonsEnabled ? _readWholeDoc : () {},
65-
padding: EdgeInsets.all(5),
6667
),
6768
Padding(
6869
child: Text(
6970
_pdfDoc == null
7071
? "Pick a new PDF document and wait for it to load..."
71-
: "PDF document loaded, ${_pdfDoc.length} pages\n",
72+
: "PDF document loaded, ${_pdfDoc!.length} pages\n",
7273
style: TextStyle(fontSize: 18),
7374
textAlign: TextAlign.center,
7475
),
@@ -91,9 +92,11 @@ class _MyAppState extends State<MyApp> {
9192

9293
/// Picks a new PDF document from the device
9394
Future _pickPDFText() async {
94-
File file = await FilePicker.getFile();
95-
_pdfDoc = await PDFDoc.fromFile(file);
96-
setState(() {});
95+
var filePickerResult = await FilePicker.platform.pickFiles();
96+
if (filePickerResult != null) {
97+
_pdfDoc = await PDFDoc.fromPath(filePickerResult.files.single.path!);
98+
setState(() {});
99+
}
97100
}
98101

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

108111
String text =
109-
await _pdfDoc.pageAt(Random().nextInt(_pdfDoc.length) + 1).text;
112+
await _pdfDoc!.pageAt(Random().nextInt(_pdfDoc!.length) + 1).text;
110113

111114
setState(() {
112115
_text = text;
@@ -123,7 +126,7 @@ class _MyAppState extends State<MyApp> {
123126
_buttonsEnabled = false;
124127
});
125128

126-
String text = await _pdfDoc.text;
129+
String text = await _pdfDoc!.text;
127130

128131
setState(() {
129132
_text = text;

0 commit comments

Comments
 (0)