Skip to content

NoSuchMethodError: _layout! null check in build() when LayoutBuilder receives zero-height constraints #646

Description

@chan-vince

On Flutter web, PdfViewer crashes with NoSuchMethodError: Null check operator used on a null value at pdf_viewer.dart:525 (_layout!.documentSize) when its LayoutBuilder fires with maxHeight <= 0 — e.g. during a route transition that briefly collapses the parent's height.

_updateLayout early-returns when viewSize.height <= 0 (per its comment, this exists to fix a blank PDF when restoring a window from minimize on Windows) and leaves _layout null, but build() then force-unwraps it on the same frame.

The text-selection branch (:547 in 2.2.24, :674 in 2.4.1) has the same _layout! unwrap.

Stack:

NoSuchMethodError: Null check operator used on a null value
  at _PdfViewerState.build.<anonymous function>.<anonymous function>
     (pdfrx-2.2.24/lib/src/widgets/pdf_viewer.dart:525:48)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions