buildCloseButton method
Widget
buildCloseButton
()
Implementation
Widget buildCloseButton() {
const internalClickAreaPadding = 2.0;
//
if (showCloseButton == ShowCloseButton.none) {
return new SizedBox();
}
// ---
double right;
double top;
switch (popupDirection) {
//
// LEFT: -------------------------------------
case TooltipDirection.left:
right = arrowLength + arrowTipDistance + 3.0;
if (showCloseButton == ShowCloseButton.inside) {
top = 2.0;
} else if (showCloseButton == ShowCloseButton.outside) {
top = 0.0;
} else
throw AssertionError(showCloseButton);
break;
// RIGHT/UP: ---------------------------------
case TooltipDirection.right:
case TooltipDirection.up:
right = 5.0;
if (showCloseButton == ShowCloseButton.inside) {
top = 2.0;
} else if (showCloseButton == ShowCloseButton.outside) {
top = 0.0;
} else
throw AssertionError(showCloseButton);
break;
// DOWN: -------------------------------------
case TooltipDirection.down:
// If this value gets negative the Shadow gets clipped. The problem occurs is arrowlength + arrowTipDistance
// is smaller than _outSideCloseButtonPadding which would mean arrowLength would need to be increased if the button is ouside.
right = 2.0;
if (showCloseButton == ShowCloseButton.inside) {
top = arrowLength + arrowTipDistance + 2.0;
} else if (showCloseButton == ShowCloseButton.outside) {
top = 0.0;
} else
throw AssertionError(showCloseButton);
break;
// ---------------------------------------------
default:
throw AssertionError(popupDirection);
}
// ---
return Positioned(
right: right,
top: top,
child: GestureDetector(
onTap: close,
child: Padding(
padding: const EdgeInsets.all(internalClickAreaPadding),
child: Icon(
Icons.close,
size: closeButtonSize,
color: closeButtonColor,
),
),
));
}