Positioned.directional constructor

Positioned.directional({
  1. Key? key,
  2. required TextDirection textDirection,
  3. double? start,
  4. double? top,
  5. double? end,
  6. double? bottom,
  7. double? width,
  8. double? height,
  9. required Widget child,
})

Creates a widget that controls where a child of a Stack is positioned.

Only two out of the three horizontal values (start, end, width), and only two out of the three vertical values (top, bottom, height), can be set. In each case, at least one of the three must be null.

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.

See also:

Implementation

factory Positioned.directional({
  Key? key,
  required TextDirection textDirection,
  double? start,
  double? top,
  double? end,
  double? bottom,
  double? width,
  double? height,
  required Widget child,
}) {
  final (double? left, double? right) = switch (textDirection) {
    TextDirection.rtl => (end, start),
    TextDirection.ltr => (start, end),
  };
  return Positioned(
    key: key,
    left: left,
    top: top,
    right: right,
    bottom: bottom,
    width: width,
    height: height,
    child: child,
  );
}