MarginSpec.fromPercent constructor
Create MarginSpec that specifies min/max percentage.
minPercent
if set must be between 0 and 100 inclusive. If maxPercent
is also set, then must be less than maxPercent
.
maxPercent
if set must be between 0 and 100 inclusive.
Implementation
factory MarginSpec.fromPercent({int? minPercent, int? maxPercent}) {
// Percent must be within 0 to 100
assert(minPercent == null || (minPercent >= 0 && minPercent <= 100));
assert(maxPercent == null || (maxPercent >= 0 && maxPercent <= 100));
// Min must be less than or equal to max.
// Can be equal to enforce strict percentage.
if (minPercent != null && maxPercent != null) {
assert(minPercent <= maxPercent);
}
return MarginSpec._internal(null, null, minPercent, maxPercent);
}