MarginSpec.fromPixel constructor

MarginSpec.fromPixel({
  1. int? minPixel,
  2. int? maxPixel,
})

Create MarginSpec that specifies min/max pixels.

minPixel if set must be greater than or equal to 0 and less than max if it is also set. maxPixel if set must be greater than or equal to 0.

Implementation

factory MarginSpec.fromPixel({int? minPixel, int? maxPixel}) {
  // Require zero or higher settings if set
  assert(minPixel == null || minPixel >= 0);
  assert(maxPixel == null || maxPixel >= 0);
  // Min must be less than or equal to max.
  // Can be equal to enforce strict pixel size.
  if (minPixel != null && maxPixel != null) {
    assert(minPixel <= maxPixel);
  }

  return MarginSpec._internal(minPixel, maxPixel, null, null);
}