dev
dart 38 lines 1.1 KB
Raw
1 import 'package:flutter/material.dart';
2
3 class RoundedIconButton extends StatelessWidget {
4 const RoundedIconButton(
5 {this.icon,
6 this.iconWidget,
7 required this.onPressed,
8 this.shape,
9 this.width,
10 this.height,
11 this.iconSize,
12 this.fillColor});
13
14 final IconData? icon;
15 final Widget? iconWidget;
16 final VoidCallback onPressed;
17 final ShapeBorder? shape;
18 final double? width;
19 final double? height;
20 final double? iconSize;
21 final Color? fillColor;
22
23 @override
24 Widget build(BuildContext context) {
25 final colorScheme = Theme.of(context).colorScheme;
26 return RawMaterialButton(
27 onPressed: onPressed,
28 fillColor: fillColor ?? colorScheme.surfaceContainerHighest,
29 elevation: 0,
30 constraints: BoxConstraints.tightFor(width: width ?? 30, height: height ?? 30),
31 padding: EdgeInsets.zero,
32 materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
33 shape: shape ?? const CircleBorder(),
34 child: icon != null
35 ? Icon(icon, size: iconSize ?? 14, color: colorScheme.onSurface)
36 : iconWidget);
37 }
38 }