iterateLaidOutPages method

Iterable<Widget> iterateLaidOutPages(
  1. Size viewSize
)

Implementation

Iterable<Widget> iterateLaidOutPages(Size viewSize) sync* {
  if (!_firstControllerAttach && _pages != null) {
    final m = _controller.value;
    final r = m.row0[0];
    final exposed =
        Rect.fromLTWH(-m.row0[3], -m.row1[3], viewSize.width, viewSize.height)
            .inflate(_padding);

    for (final page in _pages!) {
      if (page.rect == null) continue;
      final pageRectZoomed = Rect.fromLTRB(page.rect!.left * r,
          page.rect!.top * r, page.rect!.right * r, page.rect!.bottom * r);
      final part = pageRectZoomed.intersect(exposed);
      page.isVisibleInsideView = !part.isEmpty;
      if (!page.isVisibleInsideView) continue;

      yield Positioned(
        left: page.rect!.left,
        top: page.rect!.top,
        width: page.rect!.width,
        height: page.rect!.height,
        child: Container(
          width: page.rect!.width,
          height: page.rect!.height,
          decoration: widget.params?.pageDecoration ??
              const BoxDecoration(
                  color: Color.fromARGB(255, 250, 250, 250),
                  boxShadow: [
                    BoxShadow(
                        color: Colors.black45,
                        blurRadius: 4,
                        offset: Offset(2, 2))
                  ]),
          child: Stack(children: [
            ValueListenableBuilder<int>(
                valueListenable: page._previewNotifier,
                builder: (context, value, child) => page.preview != null
                    ? Positioned.fill(
                        child: PdfTexture(textureId: page.preview!.texId))
                    : widget.params?.buildPagePlaceholder != null
                        ? widget.params!.buildPagePlaceholder!(
                            context, page.pageNumber, page.rect!)
                        : Container()),
            ValueListenableBuilder<_RealSize?>(
                valueListenable: page.realSize,
                builder: (context, realSize, child) => realSize != null
                    ? Positioned(
                        left: realSize.rect.left,
                        top: realSize.rect.top,
                        width: realSize.rect.width,
                        height: realSize.rect.height,
                        child: PdfTexture(textureId: realSize.texture.texId))
                    : Container()),
            if (widget.params?.buildPageOverlay != null)
              widget.params!.buildPageOverlay!(
                  context, page.pageNumber, page.rect!),
          ]),
        ),
      );
    }
  }
}