import 'package:flutter/material.dart'; class MIconButton extends StatelessWidget { const MIconButton({ super.key, this.icon, this.onPressed, this.isSelected = false, this.selectedSrc, this.src, }); final bool isSelected; final Widget? icon; final VoidCallback? onPressed; final String? src; final String? selectedSrc; @override Widget build(BuildContext context) { const s = 46.0; Widget wIcon = src != null ? Image.asset( src!, width: s, height: s, ) : icon!; final children = [ SizedBox( width: s, height: s, child: wIcon) ]; if(onPressed==null){ children.add(Container( height: 36, width: 36, margin: const EdgeInsets.all(5), decoration: BoxDecoration( color: Colors.white.withAlpha(180), borderRadius: BorderRadius.circular(5)), )); } if (isSelected && onPressed != null) { children.add(Image.asset( selectedSrc ?? 'assets/images/btn_boader.png', width: s, height: s, )); } return GestureDetector( onTap: onPressed, child: Stack( children: children, ), ); } }