Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/pdfx/lib/src/viewer/pinch/pdf_view_pinch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,18 @@ class _PdfViewPinchState extends State<PdfViewPinch>
-m.row0[3], -m.row1[3], _lastViewSize!.width, _lastViewSize!.height);

if (_lastViewSize?.height != null) {
final rawDocumentProgress =
// Cuando el documento cabe exactamente en el viewport (o cuando ambos
// aún miden 0 en el primer frame en Android edge-to-edge), el divisor
// (_docSize.height - _lastViewSize.height) es 0 y produce NaN/Infinity.
// Sin este guard, .round() crashea con "Infinity or NaN toInt" y el
// PDF se queda en blanco. Al normalizar a 0.0 el progreso es
// consistente: no hay recorrido pendiente cuando todo cabe en pantalla.
var rawDocumentProgress =
((exposed.bottom / r - _lastViewSize!.height) /
(_docSize!.height - _lastViewSize!.height));
if (rawDocumentProgress.isNaN || rawDocumentProgress.isInfinite) {
rawDocumentProgress = 0.0;
}
const precisionFactor = 10000;
_controller._documentProgress =
((rawDocumentProgress * precisionFactor).round() / precisionFactor)
Expand Down