lessonScoreLayout function

LessonScoreLayout lessonScoreLayout(
  1. double widthPx, {
  2. double? heightPx,
  3. DeviceKind? kind,
  4. double? pixelRatio,
})

Implementation

LessonScoreLayout lessonScoreLayout(
  double widthPx, {
  double? heightPx,
  DeviceKind? kind,
  double? pixelRatio,
}) {
  final device = kind ?? currentDeviceKind;
  final margin = lessonMarginFor(kind: device);
  return LessonScoreLayout(
    pageWidth: widthPx.round().clamp(kLessonMinWidth, kLessonMaxWidth),
    pageHeight:
        heightPx?.round().clamp(kVerovioMinPageHeight, kLessonPageHeight) ??
        kLessonPageHeight,
    options: {
      ...lessonScoreOptions,
      'pageMarginLeft': margin,
      'pageMarginRight': margin,
      'unit': switch (device) {
        DeviceKind.phone => kPhoneUnit,
        DeviceKind.tablet => tabletUnit(pixelRatio ?? currentPixelRatio),
        // A largura chega em pixels do aparelho: o `unit` segue a densidade.
        DeviceKind.desktop => screenUnit(
          (lessonScoreOptions['unit']! as num).toDouble(),
          pixelRatio ?? currentPixelRatio,
        ),
      },
    },
  );
}