iconButton method
Widget
iconButton(
- BuildContext context,
- IconData icon, {
- Function? onTap,
- bool filled = false,
- Color? iconColor,
Implementation
Widget iconButton(BuildContext context, IconData icon,
{Function? onTap, bool filled = false, Color? iconColor}) {
return ElevatedButton(
onPressed: () {
if (onTap != null) onTap();
},
style: ButtonStyle(
elevation: MaterialStateProperty.all(filled ? 2 : 0),
shape: MaterialStateProperty.all(CircleBorder()),
padding: MaterialStateProperty.all(
EdgeInsets.all(DUI.spacing.lateralPaddingValue)),
backgroundColor: MaterialStateProperty.all(filled
? Theme.of(context).colorScheme.background
: Colors.transparent),
surfaceTintColor: MaterialStateProperty.all(filled
? Theme.of(context).colorScheme.background
: Colors.transparent),
overlayColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.pressed) ||
states.contains(MaterialState.hovered)) {
return Theme.of(context)
.textTheme
.bodyMedium!
.color!
.withOpacity(0.1);
}
return null;
}),
),
child: Icon(
icon,
color: iconColor ?? Theme.of(context).colorScheme.primary,
));
}