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
Aleksei
2024-01-19 17:16:34 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
David PHAM-VAN
2024-01-27 12:11:28 -0400
Commit
1b9e77e5dab0393e16f9ed9faa5e46a76d1fea52
1b9e77e5
1 parent
60342b50
Implement `scrollToPage` method
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
printing/lib/src/preview/custom.dart
printing/lib/src/preview/custom.dart
View file @
1b9e77e
...
...
@@ -110,6 +110,8 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
with
PdfPreviewRaster
{
final
listView
=
GlobalKey
();
late
List
<
GlobalKey
>
_pageGlobalKeys
;
bool
infoLoaded
=
false
;
int
?
preview
;
...
...
@@ -172,6 +174,28 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
super
.
didChangeDependencies
();
}
@override
void
initState
()
{
super
.
initState
();
_pageGlobalKeys
=
List
.
generate
(
pages
.
length
,
(
index
)
=>
GlobalKey
(
debugLabel:
'pdf-page-
$index
'
),
);
}
void
scrollToPage
(
int
index
,
{
Duration
duration
=
Duration
.
zero
,
Curve
curve
=
Curves
.
ease
,
ScrollPositionAlignmentPolicy
alignmentPolicy
=
ScrollPositionAlignmentPolicy
.
explicit
,
})
{
assert
(
index
>=
0
);
final
pageKey
=
_pageGlobalKeys
[
index
];
Scrollable
.
ensureVisible
(
pageKey
.
currentContext
!,
duration:
duration
,
curve:
curve
,
alignmentPolicy:
alignmentPolicy
);
}
Widget
_showError
(
Object
error
)
{
if
(
widget
.
onError
!=
null
)
{
return
widget
.
onError
!(
context
,
error
);
...
...
@@ -215,6 +239,7 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
});
},
child:
PdfPreviewPage
(
key:
_pageGlobalKeys
[
index
],
pageData:
pages
[
index
],
pdfPreviewPageDecoration:
widget
.
pdfPreviewPageDecoration
,
pageMargin:
widget
.
previewPageMargin
,
...
...
Please
register
or
login
to post a comment