Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2020-04-03 14:04:35 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a123c5f4a666025be7195a6f30dab450db56dc34
a123c5f4
1 parent
7611e45b
Remove width and height parameters from wrapWidget helper
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
36 deletions
printing/CHANGELOG.md
printing/lib/src/widget_wrapper.dart
printing/pubspec.yaml
printing/CHANGELOG.md
View file @
a123c5f
# Changelog
## 3.3.1
-
Remove width and height parameters from wrapWidget helper
## 3.3.0
-
Add wrapWidget helper
...
...
printing/lib/src/widget_wrapper.dart
View file @
a123c5f
...
...
@@ -35,44 +35,10 @@ Future<PdfImage> wrapWidget(
final
RenderRepaintBoundary
wrappedWidget
=
key
.
currentContext
.
findRenderObject
();
ui
.
Image
image
=
await
wrappedWidget
.
toImage
(
pixelRatio:
pixelRatio
);
image
=
await
_resize
(
image
,
width
,
height
);
final
ui
.
Image
image
=
await
wrappedWidget
.
toImage
(
pixelRatio:
pixelRatio
);
final
ByteData
byteData
=
await
image
.
toByteData
(
format:
ui
.
ImageByteFormat
.
rawRgba
);
final
Uint8List
imageData
=
byteData
.
buffer
.
asUint8List
();
return
PdfImage
(
document
,
image:
imageData
,
width:
image
.
width
,
height:
image
.
height
);
}
Future
<
ui
.
Image
>
_resize
(
ui
.
Image
image
,
int
width
,
int
height
,
)
async
{
if
(
width
==
null
&&
height
==
null
)
{
return
image
;
}
width
??=
(
height
/
image
.
height
*
image
.
width
).
toInt
();
height
??=
(
width
/
image
.
width
*
image
.
height
).
toInt
();
final
Completer
<
ui
.
Image
>
ptr
=
Completer
<
ui
.
Image
>();
final
Uint8List
data
=
(
await
image
.
toByteData
(
format:
ui
.
ImageByteFormat
.
rawRgba
))
.
buffer
.
asUint8List
();
ui
.
decodeImageFromPixels
(
data
,
image
.
width
,
image
.
height
,
ui
.
PixelFormat
.
rgba8888
,
(
ui
.
Image
result
)
{
ptr
.
complete
(
result
);
},
targetWidth:
width
,
targetHeight:
height
,
);
return
ptr
.
future
;
}
...
...
printing/pubspec.yaml
View file @
a123c5f
...
...
@@ -4,7 +4,7 @@ description: Plugin that allows Flutter apps to generate and print documents to
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/printing
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
3.3.
0
version
:
3.3.
1
environment
:
sdk
:
"
>=2.3.0
<3.0.0"
...
...
Please
register
or
login
to post a comment