Line data Source code
1 : import 'package:flutter/material.dart';
2 :
3 : class CircleIconButton extends StatelessWidget {
4 : final Color backgroundColor;
5 : final Color splashColor;
6 : final Color loadingColor;
7 : final num radius;
8 : final Icon icon;
9 : final BoxShadow shadow;
10 : final bool displayShadow;
11 : final Function onTapCallback;
12 : final bool isLoading;
13 7 : const CircleIconButton({
14 : Key key,
15 : this.backgroundColor = Colors.blue,
16 : this.loadingColor = Colors.white,
17 : this.splashColor,
18 : this.radius = 20.0,
19 : this.shadow,
20 : this.displayShadow = true,
21 : @required this.icon,
22 : this.isLoading = false,
23 : this.onTapCallback,
24 7 : }) : super(key: key);
25 :
26 7 : @override
27 : Widget build(BuildContext context) {
28 7 : return Container(
29 7 : decoration: BoxDecoration(
30 : shape: BoxShape.circle,
31 : color: Colors.transparent,
32 7 : boxShadow: displayShadow
33 7 : ? [
34 7 : shadow ??
35 7 : BoxShadow(
36 : color: Colors.black
37 14 : .withOpacity(onTapCallback != null ? 0.1 : 0.03),
38 : spreadRadius: 5,
39 : blurRadius: 9,
40 7 : offset: Offset(0, 3), // changes position of shadow
41 : ),
42 : ]
43 : : null,
44 : ),
45 7 : child: ClipOval(
46 7 : child: Opacity(
47 7 : opacity: (onTapCallback != null) ? 1 : 0.30,
48 7 : child: Material(
49 7 : color: backgroundColor,
50 7 : child: InkWell(
51 7 : splashColor: splashColor,
52 7 : child: SizedBox(
53 14 : width: radius * 2,
54 14 : height: radius * 2,
55 7 : child: (isLoading)
56 0 : ? Padding(
57 : padding: const EdgeInsets.all(12.0),
58 0 : child: CircularProgressIndicator(
59 0 : backgroundColor: loadingColor,
60 : strokeWidth: 2.0,
61 : ),
62 : )
63 7 : : icon,
64 : ),
65 7 : onTap: onTapCallback,
66 : ),
67 : ),
68 : ),
69 : ),
70 : );
71 : }
72 : }
|