Skip to content

Commit

Permalink
Skip rendering the first page if an initialPageNumber specified
Browse files Browse the repository at this point in the history
  • Loading branch information
yhyh0 committed Apr 12, 2024
1 parent 1c91c05 commit 8048a50
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/src/widgets/pdf_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ class _PdfViewerState extends State<PdfViewer>
}

if (!_initialized && _layout != null) {
_initialized = true;
Future.microtask(() async {
if (mounted) {
final initialPageNumber = widget.params.calculateInitialPageNumber
Expand All @@ -394,6 +393,7 @@ class _PdfViewerState extends State<PdfViewer>
widget.params.onViewerReady?.call(_document!, _controller!);
}
}
_initialized = true;
});
}

Expand Down Expand Up @@ -428,11 +428,13 @@ class _PdfViewerState extends State<PdfViewer>
? _onWheelDelta
: null,
// PDF pages
child: CustomPaint(
foregroundPainter:
_CustomPainter.fromFunction(_customPaint),
size: _layout!.documentSize,
),
child: _initialized
? CustomPaint(
foregroundPainter:
_CustomPainter.fromFunction(_customPaint),
size: _layout!.documentSize,
)
: Container(),
),
..._buildPageOverlayWidgets(),
if (widget.params.viewerOverlayBuilder != null)
Expand Down

0 comments on commit 8048a50

Please sign in to comment.