setIconButton method

IconButton setIconButton(
  1. String icon,
  2. VoidCallback voidCallBack, {
  3. double? height = 25,
  4. double? width = 25,
  5. Color? iconColor,
})

Creates an icon button from an asset image.

Wraps an asset image in an IconButton with customizable sizing and color.

Parameters:

  • icon: Path to the asset image.
  • voidCallBack: Callback function triggered when the button is pressed.
  • height: Height of the icon image (defaults to 25).
  • width: Width of the icon image (defaults to 25).
  • iconColor: Optional tint color for the icon.

Returns an IconButton containing the asset image.

Example:

setIconButton(
  'assets/icons/settings.png',
  () => navigateToSettings(),
  height: 30,
  width: 30,
  iconColor: Colors.blue,
);

Implementation

IconButton setIconButton(String icon, VoidCallback voidCallBack,
    {double? height = 25, double? width = 25, Color? iconColor}) {
  return IconButton(
    icon: Image.asset(
      icon,
      color: iconColor,
      height: height,
      width: width,
    ),
    onPressed: voidCallBack,
  );
}