import 'package:flutter/material.dart'; class CustomIconButton extends StatelessWidget { CustomIconButton({ Key? key, this.alignment, this.height, this.width, this.padding, this.decoration, this.child, this.onTap, }) : super(key: key); final Alignment? alignment; final double? height; final double? width; final EdgeInsetsGeometry? padding; final BoxDecoration? decoration; final Widget? child; final VoidCallback? onTap; @override Widget build(BuildContext context) { return alignment != null ? Align( alignment: alignment ?? Alignment.center, child: _buildIconButtonWidget(), ) : _buildIconButtonWidget(); } _buildIconButtonWidget() { return SizedBox( height: height ?? 0, width: width ?? 0, child: IconButton( padding: EdgeInsets.zero, icon: Container( height: height ?? 0, width: width ?? 0, padding: padding ?? EdgeInsets.zero, decoration: decoration ?? BoxDecoration( color: Colors.black, borderRadius: const BorderRadius.all(Radius.circular(9)), border: const Border.fromBorderSide( BorderSide(color: Colors.blueGrey, width: 1)), ), child: child, ), onPressed: onTap, ), ); } } /// Extension on [CustomIconButton] to facilitate inclusion of all types of border style etc extension IconButtonStyleHelper on CustomIconButton { static BoxDecoration get fillBlueA => BoxDecoration( color: Colors.blue, borderRadius: const BorderRadius.all(Radius.circular(14)), ); }