closeButton method

Widget closeButton(
  1. dynamic context, {
  2. required VoidCallback onTap,
  3. required AlignmentGeometry alignment,
  4. double? iconSize,
  5. bool isCircleIcon = false,
})

Implementation

Widget closeButton(
  context, {
  required VoidCallback onTap,
  required AlignmentGeometry alignment,
  double? iconSize,
  bool isCircleIcon = false,
}) {
  var decoration = isCircleIcon
      ? ShapeDecoration(
          shape: CircleBorder(
            side: BorderSide(
              color: Theme.of(context).colorScheme.secondary,
              width: 1.0,
            ),
          ),
          color: Theme.of(context).colorScheme.surface,
        )
      : BoxDecoration(
          borderRadius: const BorderRadius.all(Radius.circular(10)),
          color: Theme.of(context).colorScheme.surface,
        );

  return Align(
    alignment: alignment,
    child: GestureDetector(
      onTap: onTap,
      child: Container(
        width: iconSize ?? 25,
        height: iconSize ?? 25,
        padding: isCircleIcon ? null : const EdgeInsets.all(4),
        decoration: decoration,
        child: FittedBox(
          fit: BoxFit.contain,
          child: Icon(
            Icons.close_rounded,
            color: Theme.of(context).colorScheme.secondary,
          ),
        ),
      ),
    ),
  );
}