screenSize static method

Size screenSize(
  1. BuildContext context
)

Returns the canonical design size for the current device configuration. Reads MediaQuery once for efficiency. Sizes are sourced from VirnaviUIBootstrap.init.

Implementation

static Size screenSize(BuildContext context) {
  final media = MediaQuery.of(context);
  final size = media.size;
  final isLandscape = media.orientation == Orientation.landscape;
  final aspectRatio = size.width / size.height;

  final isSplit = (aspectRatio > 0.8 && aspectRatio < 1.2) ||
      (isLandscape && aspectRatio < 1.5);

  if (isSplit || size.shortestSide < 600) {
    final portrait = VirnaviUIBootstrap.mobileDesignSize;
    return isLandscape ? Size(portrait.height, portrait.width) : portrait;
  }
  final portrait = VirnaviUIBootstrap.tabletDesignSize;
  return isLandscape ? Size(portrait.height, portrait.width) : portrait;
}