tapImage static method
Widget
tapImage(
- String? imageName,
- VoidCallback onTap, {
- double? width,
- double? height,
- double? size,
- BoxFit fit = BoxFit.contain,
- bool excludeFromSemantics = false,
- double? paddingH = 0,
- double? paddingV = 0,
- bool gaplessPlayback = false,
- Color? imageColor,
- bool primary = false,
- BuildContext? context,
- bool disabled = false,
Implementation
static Widget tapImage(String? imageName, VoidCallback onTap,
{double? width, double? height, double? size, BoxFit fit = BoxFit.contain,
bool excludeFromSemantics = false, double? paddingH = 0, double? paddingV = 0,
bool gaplessPlayback = false, Color? imageColor, bool primary = false, BuildContext? context,
bool disabled = false,}) {
var maxValue = max(max(width ?? 0, height ?? 0), size ?? 0);
if (imageName == null || imageName.isEmpty) {
return SizedBox(width: maxValue, height: maxValue,);
}
var imageWidget = Container(
padding: EdgeInsets.symmetric(
horizontal: paddingH ?? 0, vertical: paddingV ?? 0),
child: image(imageName, width: width ?? maxValue, height: height ?? maxValue,
fit: fit, excludeFromSemantics: excludeFromSemantics, gaplessPlayback: gaplessPlayback,),
);
return GestureDetector(behavior: HitTestBehavior.translucent,
onTap: disabled ? null : onTap, child: Opacity(opacity: disabled?0.5:1,
child: imageColor != null || (primary && context != null)
? ColorFiltered(colorFilter: ColorFilter.mode(
primary ? Theme.of(context!).colorScheme.primary : imageColor!, BlendMode.srcIn),
child: imageWidget,) : imageWidget,),
);
}