-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_button.dart
88 lines (83 loc) · 2.51 KB
/
custom_button.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import 'package:flutter/material.dart';
import 'package:futara/controller/resources/theme/colors_manager.dart';
import 'package:futara/view/widgets/my_text.dart';
class CustomButton extends StatelessWidget {
const CustomButton({
Key? key,
this.text,
this.borderRadius,
this.color,
this.onTap,
this.contentColor,
this.width,
this.height,
this.borderColor,
this.loading,
this.hideIcon = false,
this.padding,
this.textDirection,
this.child,
this.iconSize,
this.radius,
this.fontSize,
this.fontWeight,
}) : super(key: key);
final Color? color, borderColor, contentColor;
final BorderRadius? borderRadius;
final EdgeInsets? padding;
final TextDirection? textDirection;
final Function? onTap;
final String? text;
final double? width, height, iconSize, radius, fontSize;
final FontWeight? fontWeight;
final bool? loading;
final bool? hideIcon;
final Widget? child;
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: textDirection ?? TextDirection.rtl,
child: Container(
width: width,
height: height,
margin: const EdgeInsets.only(top: 10),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 0.0,
backgroundColor: color ?? AppColors.blueColor,
padding: padding ??
const EdgeInsets.symmetric(horizontal: 2, vertical: 2),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: borderColor ?? Colors.transparent,
width: 2,
),
),
),
onPressed:
loading! /*.value*/ || onTap == null ? null : () => onTap!.call(),
child: loading! /*.value*/
? const Center(
child: CircularProgressIndicator(
color: Colors.white,
),
)
: child ??
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
MyText(
title: text!,
color: contentColor ?? Colors.white,
fontSize: fontSize,
fontWeight: fontWeight,
),
],
),
),
),
);
}
}