relative static method
Widget
relative(
- Widget main,
- Widget relative, {
- Key? key,
- Widget? child,
- Alignment? alignment,
- double? dx,
- double? dy,
- double? moveByChildWidth,
- double? moveByChildHeight,
- double? moveByContainerWidth,
- double? moveByContainerHeight,
- double? moveVerticallyByChildWidth,
- double? moveHorizontallyByChildHeight,
- double? moveVerticallyByContainerWidth,
- double? moveHorizontallyByContainerHeight,
- double? childWidth,
- double? childHeight,
- double? minChildWidth,
- double? minChildHeight,
- double? maxChildWidth,
- double? maxChildHeight,
- double? childWidthRatio,
- double? childHeightRatio,
- double? minChildWidthRatio,
- double? minChildHeightRatio,
- double? maxChildWidthRatio,
- double? maxChildHeightRatio,
- double? rotateDegrees,
- Matrix4Transform? matrix4Transform,
- Wins wins = Wins.min,
- Touch touch = Touch.inside,
Use this if you have a main widget, and you want to position/size/rotate/translate another widget relative to the main one, but the second is NOT a child of the first.
Example, to center the main widget, and then put the relative widget below it:
Center(
child: AlignPositioned.relative(
widgetA(),
widgetB(),
moveByContainerHeight: 0.5,
moveByChildHeight: 0.5));
Implementation
static Widget relative(
Widget main,
Widget relative, {
Key? key,
Widget? child,
Alignment? alignment,
double? dx,
double? dy,
double? moveByChildWidth,
double? moveByChildHeight,
double? moveByContainerWidth,
double? moveByContainerHeight,
double? moveVerticallyByChildWidth,
double? moveHorizontallyByChildHeight,
double? moveVerticallyByContainerWidth,
double? moveHorizontallyByContainerHeight,
double? childWidth,
double? childHeight,
double? minChildWidth,
double? minChildHeight,
double? maxChildWidth,
double? maxChildHeight,
double? childWidthRatio,
double? childHeightRatio,
double? minChildWidthRatio,
double? minChildHeightRatio,
double? maxChildWidthRatio,
double? maxChildHeightRatio,
double? rotateDegrees,
Matrix4Transform? matrix4Transform,
Wins wins = Wins.min,
Touch touch = Touch.inside,
}) {
return Stack(children: [
main,
AlignPositioned.expand(
child: relative,
alignment: alignment,
dx: dx,
dy: dy,
moveByChildWidth: moveByChildWidth,
moveByChildHeight: moveByChildHeight,
moveByContainerWidth: moveByContainerWidth,
moveByContainerHeight: moveByContainerHeight,
moveVerticallyByChildWidth: moveVerticallyByChildWidth,
moveHorizontallyByChildHeight: moveHorizontallyByChildHeight,
moveVerticallyByContainerWidth: moveVerticallyByContainerWidth,
moveHorizontallyByContainerHeight: moveHorizontallyByContainerHeight,
childWidth: childWidth,
childHeight: childHeight,
minChildWidth: minChildWidth,
minChildHeight: minChildHeight,
maxChildWidth: maxChildWidth,
maxChildHeight: maxChildHeight,
childWidthRatio: childWidthRatio,
childHeightRatio: childHeightRatio,
minChildWidthRatio: minChildWidthRatio,
minChildHeightRatio: minChildHeightRatio,
maxChildWidthRatio: maxChildWidthRatio,
maxChildHeightRatio: maxChildHeightRatio,
rotateDegrees: rotateDegrees,
matrix4Transform: matrix4Transform,
wins: wins,
touch: touch,
),
]);
}