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-22 08:18:36 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
David PHAM-VAN
2024-01-27 12:11:28 -0400
Commit
1c895b099a86881c9e27d6f667a66e1ef09c77dc
1c895b09
1 parent
ff7a0594
Make `pageGlobalKeys` populated once
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
printing/lib/src/preview/custom.dart
printing/lib/src/preview/custom.dart
View file @
1c895b0
...
...
@@ -110,7 +110,7 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
with
PdfPreviewRaster
{
final
listView
=
GlobalKey
();
late
List
<
GlobalKey
>
_pageGlobalKeys
;
List
<
GlobalKey
>
_pageGlobalKeys
=
<
GlobalKey
>[]
;
bool
infoLoaded
=
false
;
...
...
@@ -174,6 +174,7 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
super
.
didChangeDependencies
();
}
/// Ensures that page with [index] is become visible.
Future
<
void
>
scrollToPage
(
int
index
,
{
Duration
duration
=
const
Duration
(
milliseconds:
300
),
...
...
@@ -188,6 +189,9 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
duration:
duration
,
curve:
curve
,
alignmentPolicy:
alignmentPolicy
);
}
/// Returns the global key for page with [index].
Key
getPageKey
(
int
index
)
=>
_pageGlobalKeys
[
index
];
Widget
_showError
(
Object
error
)
{
if
(
widget
.
onError
!=
null
)
{
return
widget
.
onError
!(
context
,
error
);
...
...
@@ -213,10 +217,12 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
);
}
_pageGlobalKeys
=
List
.
generate
(
pages
.
length
,
(
index
)
=>
GlobalKey
(
debugLabel:
'pdf-page-
$index
'
),
);
if
(
_pageGlobalKeys
.
isEmpty
)
{
_pageGlobalKeys
=
List
.
generate
(
pages
.
length
,
(
index
)
=>
GlobalKey
(
debugLabel:
'pdf-page-
$index
'
),
);
}
if
(
widget
.
pagesBuilder
!=
null
)
{
return
widget
.
pagesBuilder
!(
context
,
pages
);
...
...
@@ -237,7 +243,7 @@ class PdfPreviewCustomState extends State<PdfPreviewCustom>
});
},
child:
PdfPreviewPage
(
key:
_pageGlobalKeys
[
index
]
,
key:
getPageKey
(
index
)
,
pageData:
pages
[
index
],
pdfPreviewPageDecoration:
widget
.
pdfPreviewPageDecoration
,
pageMargin:
widget
.
previewPageMargin
,
...
...
Please
register
or
login
to post a comment