primary static method
Widget
primary({
- required String text,
- required VoidCallback? onPressed,
- bool loading = false,
- ButtonSize size = ButtonSize.md,
- Widget? prefixIcon,
- Widget? suffixIcon,
- Color? backgroundColor,
- Color? textColor,
- bool? showShadow,
- MaterialTapTargetSize? tapTargetSize,
- bool stretch = true,
- Color? boarderColor,
- EdgeInsetsGeometry margin = EdgeInsets.zero,
- EdgeInsetsGeometry? padding,
Implementation
static Widget primary(
{required String text,
required VoidCallback? onPressed,
bool loading = false,
ButtonSize size = ButtonSize.md,
Widget? prefixIcon,
Widget? suffixIcon,
Color? backgroundColor,
Color? textColor,
bool? showShadow,
MaterialTapTargetSize? tapTargetSize,
bool stretch = true,
Color? boarderColor,
EdgeInsetsGeometry margin = EdgeInsets.zero,
EdgeInsetsGeometry? padding}) {
return Padding(
padding: margin,
child: TextButton(
style: TextButton.styleFrom(
tapTargetSize: tapTargetSize,
minimumSize: Size(stretch ? double.infinity : 0, 0.0),
padding: padding ?? size.titlePadding,
shape: rectBorderRadiusX(40, boarderColor),
backgroundColor: backgroundColor ?? KashiColors.primaryColor),
onPressed: !loading
? () {
HapticFeedback.lightImpact();
onPressed?.call();
}
: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: stretch ? MainAxisSize.max : MainAxisSize.min,
children: [
loading
? Container(
margin: const EdgeInsets.only(right: 12),
width: 12,
height: 12,
child: const CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
: const SizedBox.shrink(),
if (prefixIcon != null)
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: prefixIcon,
),
Flexible(
child: Text(
text,
style: KashiTheme.sh2SemiBold
.copyWith(color: textColor ?? Colors.white)
.copyWith(
fontWeight: size.fontWeight,
fontSize: size.fontSize,
)
.toDMSanFontsFamily(),
),
),
if (suffixIcon != null)
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: suffixIcon,
),
],
)),
);
}