Skip to content

Commit

Permalink
Merge pull request #18 from lively-bigyan/dev
Browse files Browse the repository at this point in the history
Upgraded dependencies and some minor fixes.
  • Loading branch information
erluxman authored Jan 25, 2021
2 parents 00d835f + 69701d9 commit 32e0b48
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 141 deletions.
33 changes: 33 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
include: package:pedantic/analysis_options.yaml
# Not happy with the default? Customize the rules depending on your needs.
# Here are some examples:
linter:
rules:
prefer_single_quotes: false
# Good packages document everything
public_member_api_docs: false

# Blindly follow the Flutter code style, which prefers types everywhere
always_specify_types: false

# Back to the 80s
lines_longer_than_120_chars: true

#prefer relative imports instead of absolute
prefer_relative_imports: true

# Use parameter order as in json response
always_put_required_named_parameters_first: true

# Util classes are awesome!
avoid_classes_with_only_static_members: false

prefer_const_declarations: true

prefer_const_constructors: true

use_rethrow_when_possible: true

unnecessary_null_in_if_null_operators: true

avoid_print: true
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.6.3'
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
141 changes: 62 additions & 79 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:pdf_flutter/pdf_flutter.dart';
Expand All @@ -13,104 +12,88 @@ class PdfApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text("pdf_flutter demo"),
title: const Text("pdf_flutter demo"),
),
body: PDFListBody(),
));
}
}

class PDFListBody extends StatefulWidget {
const PDFListBody({
Key key,
}) : super(key: key);

@override
_PDFListBodyState createState() => _PDFListBodyState();
}

class _PDFListBodyState extends State<PDFListBody> {
File localFile;

@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Column(
children: <Widget>[
Text("PDF.network(url)"),
PDF.network(
'https://google-developer-training.github.io/android-developer-fundamentals-course-concepts/en/android-developer-fundamentals-course-concepts-en.pdf',
height: 300,
width: 150,
placeHolder: Image.asset("assets/images/pdf.png",
height: 200, width: 100),
),
],
),
SizedBox(
height: 10,
),
Column(
children: <Widget>[
Text("PDF.assets(assetname)"),
PDF.assets(
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: const Text("Pdf from asset"),
onPressed: () {
_navigateToPage(
title: "Pdf from asset",
child: PDF.asset(
"assets/pdf/demo.pdf",
height: 300,
width: 150,
placeHolder: Image.asset("assets/images/pdf.png",
height: 200, width: 100),
),
],
),
],
),
SizedBox(
height: 10,
),
localFile != null
? Column(
children: <Widget>[
Text("PDF.file(fileName)"),
PDF.file(
localFile,
height: 300,
width: 200,
placeHolder: Image.asset("assets/images/pdf.png",
height: 200, width: 100),
),
],
)
: InkWell(
onTap: () async {
File file = await FilePicker.getFile(
);
},
),
RaisedButton(
child: const Text("Pdf from network"),
onPressed: () {
_navigateToPage(
title: "Pdf from networkUrl",
child: PDF.network(
'https://google-developer-training.github.io/android-developer-fundamentals-course-concepts/en/android-developer-fundamentals-course-concepts-en.pdf',
),
);
},
),
Builder(
builder: (context) {
return RaisedButton(
child: const Text("PDF from file"),
onPressed: () async {
final file = await FilePicker.platform.pickFiles(
allowedExtensions: ['pdf'], type: FileType.custom);
setState(() {
localFile = file;
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 300,
decoration: BoxDecoration(
color: Colors.cyan,
borderRadius: BorderRadius.circular(20),
),
child: Center(
child: Text(
"Select PDF from device",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 45, color: Colors.white),
if (file?.files[0]?.path != null) {
_navigateToPage(
title: "PDF from file",
child: PDF.file(
File(file.files[0].path),
),
),
),
),
)
],
);
} else {
Scaffold.of(context).showSnackBar(
const SnackBar(
content: Text("Failed to load Picked file"),
),
);
}
},
);
},
)
],
),
);
}

void _navigateToPage({String title, Widget child}) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(title: Text(title)),
body: Center(child: child),
),
),
);
}
}
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
dependencies:
flutter:
sdk: flutter
file_picker: ^1.12.0
file_picker: ^2.1.5
pdf_flutter:
path: ../

Expand Down
Loading

0 comments on commit 32e0b48

Please sign in to comment.