dvDisplayScaleFor function

double dvDisplayScaleFor(
  1. Size size, {
  2. DVDisplayScaling scaling = const DVDisplayScaling.auto(),
  3. DVScreenClass? declared,
  4. bool television = false,
  5. bool watch = false,
})

The factor the whole interface is drawn at on a screen of logical size.

Implementation

double dvDisplayScaleFor(
  Size size, {
  DVDisplayScaling scaling = const DVDisplayScaling.auto(),
  DVScreenClass? declared,
  bool television = false,
  bool watch = false,
}) {
  if (!scaling.enabled) return 1;
  if (scaling.factor != null) return scaling.factor!;
  if (size.isEmpty) return 1;
  switch (declared ?? dvScreenClassFor(size, television: television, watch: watch)) {
    case DVScreenClass.watch:
      return (size.shortestSide / _watchLayoutWidth).clamp(0.6, 1.0).toDouble();
    case DVScreenClass.tv:
    case DVScreenClass.billboard:
      final Size base = size.height > size.width ? _tenFootScreen.flipped : _tenFootScreen;
      return math.max(1, math.min(size.width / base.width, size.height / base.height)).toDouble();
    case DVScreenClass.phone:
    case DVScreenClass.tablet:
    case DVScreenClass.desktop:
      return 1;
  }
}