| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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 = <Widget>[
- 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,
- ),
- );
- }
- }
|