addPlacementForPage method

SignaturePlacement addPlacementForPage({
  1. required List<SignaturePlacement> placements,
  2. required int currentPage,
  3. double baseScale = 0.6,
})

Adds a new signature placement for the given currentPage.

placements → existing list of placements. currentPage → page where the new signature should be placed. baseScale → scale of the signature (default = 0.6).

The new placement position is offset by a fixed gap from existing signatures on that page.

Implementation

SignaturePlacement addPlacementForPage({
  required List<SignaturePlacement> placements,
  required int currentPage,
  double baseScale = 0.6,
}) {
  const double gap = 24.0;

  // Count how many signatures already exist on the page
  final countOnPage = placements.where((p) => p.page == currentPage).length;

  // Position new signature relative to the count
  return SignaturePlacement(
    offsetDx: 40 + countOnPage * gap,
    offsetDy: 120 + countOnPage * gap,
    page: currentPage,
    scale: baseScale,
  );
}