calcLeft method

num calcLeft(
  1. Rectangle<num> sourceRect, [
  2. Rectangle<num>? contentRect
])

Returns the calculated x position from sourceRect.

If contentRect is provided, it is considered to be the size of the content being aligned if it were visible.

Implementation

num calcLeft(Rectangle sourceRect, [Rectangle? contentRect]) {
  if (requiresContentSizeToPosition && contentRect == null) {
    throw ArgumentError.notNull('contentRect');
  }
  var left = sourceRect.left;
  if (this == Center) {
    left += sourceRect.width / 2 - contentRect!.width / 2;
  } else if (this == End) {
    left += sourceRect.width - contentRect!.width;
  }
  return left;
}