ResponsiveValue<T>.upto constructor

ResponsiveValue<T>.upto({
  1. bool allowNull = false,
  2. T? xlarge,
  3. T? large,
  4. T? medium,
  5. T? small,
  6. T? fallback,
})

Implementation

factory ResponsiveValue.upto({
  bool allowNull = false,
  T? xlarge,
  T? large,
  T? medium,
  T? small,
  // T? xsmall,
  T? fallback,
}) {
  T? xlargeValue;
  T? largeValue;
  T? mediumValue;
  T? smallValue;
  T? xsmallValue;

  if (xlarge != null) {
    xsmallValue = xlarge;
    smallValue = xlarge;
    mediumValue = xlarge;
    largeValue = xlarge;
    xlargeValue = xlarge;
  }

  if (large != null) {
    xsmallValue = large;
    smallValue = large;
    mediumValue = large;
    largeValue = large;
  }

  if (medium != null) {
    xsmallValue = medium;
    smallValue = medium;
    mediumValue = medium;
  }

  if (small != null) {
    xsmallValue = small;
    smallValue = small;
  }

  return ResponsiveValue(
    allowNull: allowNull,
    xsmall: xsmallValue,
    small: smallValue,
    medium: mediumValue,
    large: largeValue,
    xlarge: xlargeValue,
    fallback: fallback,
  );
}