RelativeRect.fromDirectional constructor Null safety

RelativeRect.fromDirectional(
  1. {required TextDirection textDirection,
  2. required double start,
  3. required double top,
  4. required double end,
  5. required double bottom}
)

Creates a RelativeRect from horizontal position using start and end rather than left and right.

If textDirection is TextDirection.rtl, then the start argument is used for the right property and the end argument is used for the left property. Otherwise, if textDirection is TextDirection.ltr, then the start argument is used for the left property and the end argument is used for the right property.

Implementation

factory RelativeRect.fromDirectional({
  required TextDirection textDirection,
  required double start,
  required double top,
  required double end,
  required double bottom,
}) {
  double left;
  double right;
  switch (textDirection) {
    case TextDirection.rtl:
      left = end;
      right = start;
      break;
    case TextDirection.ltr:
      left = start;
      right = end;
      break;
  }

  return RelativeRect.fromLTRB(left, top, right, bottom);
}