deviceHasFormFactor method

bool deviceHasFormFactor({
  1. AFFormFactor? atLeast,
  2. AFFormFactor? atMost,
  3. Orientation? withOrientation,
})

Implementation

bool deviceHasFormFactor({
  AFFormFactor? atLeast,
  AFFormFactor? atMost,
  Orientation? withOrientation
}) {
  if(withOrientation != null) {
    if(deviceOrientation != withOrientation) {
      return false;
    }
  }

  var atLeastIdx = 0;
  var atMostIdx = orderedFormFactors.length;
  if(atLeast != null) {
    atLeastIdx = orderedFormFactors.indexOf(atLeast);
  }
  if(atMost != null) {
    atMostIdx = orderedFormFactors.indexOf(atMost);
  }

  final actualIdx = orderedFormFactors.indexOf(deviceFormFactor);
  return (actualIdx >= atLeastIdx && actualIdx <= atMostIdx);
}