RelativeRect.fromDirectional constructor

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,
}) {
  final (double left, double right) = switch (textDirection) {
    TextDirection.rtl => (end, start),
    TextDirection.ltr => (start, end),
  };
  return RelativeRect.fromLTRB(left, top, right, bottom);
}