getWidth method
Implementation
double? getWidth({double? widthParent})
{
if (!hasBoundedWidth) return null;
double? myWidth;
// width
if (width != null)
{
myWidth = width;
}
// percentage width based on parent
else if (widthPercentage != null && widthParent != null)
{
myWidth = ((widthPercentage!/100) * widthParent);
}
// apply model constraints
if (myWidth != null)
{
// must be greater than minWidth
var minWidth = getMinWidth(widthParent: widthParent);
if (minWidth != null && myWidth < minWidth)
{
myWidth = minWidth;
}
// must be greater than maxWidth
var maxWidth = getMaxWidth(widthParent: widthParent);
if (maxWidth != null && myWidth > maxWidth)
{
myWidth = maxWidth;
}
}
// cannot be negative
if (myWidth != null && myWidth.isNegative)
{
myWidth = 0;
}
return myWidth;
}