matchesResponsivePresentation function

bool matchesResponsivePresentation({
  1. required String configuredPresentation,
  2. required String presentation,
  3. String widthBreakpoint = '',
  4. String heightBreakpoint = '',
})

Implementation

bool matchesResponsivePresentation({
  required String configuredPresentation,
  required String presentation,
  String widthBreakpoint = '',
  String heightBreakpoint = '',
}) {
  if (configuredPresentation.trim().toLowerCase() != presentation) {
    return false;
  }

  final normalizedWidthBreakpoint = widthBreakpoint.trim();
  final normalizedHeightBreakpoint = heightBreakpoint.trim();
  if (normalizedWidthBreakpoint.isEmpty && normalizedHeightBreakpoint.isEmpty) {
    return false;
  }

  final widthMatches = normalizedWidthBreakpoint.isNotEmpty &&
      html.window.matchMedia('(max-width: $normalizedWidthBreakpoint)').matches;
  final heightMatches = normalizedHeightBreakpoint.isNotEmpty &&
      html.window
          .matchMedia('(max-height: $normalizedHeightBreakpoint)')
          .matches;

  return widthMatches || heightMatches;
}