primaryButton static method
Widget
primaryButton({
- required void onPressed(),
- void onFocusChange()?,
- void onLongPress()?,
- Color? backgroundColor,
- EdgeInsetsGeometry? padding,
- MainAxisSize mainAxisSize = MainAxisSize.max,
- Widget? leadingIcon,
- Widget? trailingIcon,
- Widget? child,
- required String buttonTitle,
- TextStyle? textStyle,
- double? fontSize,
- FontWeight? textFontWeight,
- double? elevation,
- Color? textColor,
- double? borderRadius,
- bool isDisabled = false,
Implementation
static Widget primaryButton({
required void Function() onPressed,
void Function(bool)? onFocusChange,
void Function()? onLongPress,
Color? backgroundColor,
EdgeInsetsGeometry? padding,
MainAxisSize mainAxisSize = MainAxisSize.max,
Widget? leadingIcon,
Widget? trailingIcon,
Widget? child,
required String buttonTitle,
TextStyle? textStyle,
double? fontSize,
FontWeight? textFontWeight,
double? elevation,
Color? textColor,
double? borderRadius,
bool isDisabled = false,
}) {
return ElevatedButton(
onPressed: onPressed,
onFocusChange: onFocusChange,
onLongPress: onLongPress,
style: ElevatedButton.styleFrom(
overlayColor: Colors.black,
backgroundColor: isDisabled
? (backgroundColor?.withOpacity(0.5) ??
AppColors.primary.withOpacity(0.5))
: (backgroundColor ?? AppColors.primary),
padding: padding ??
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 10.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadius ?? 12.0),
),
elevation: elevation ?? 2.0,
),
child: child ??
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: mainAxisSize,
children: [
if (leadingIcon != null) ...[leadingIcon],
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text(
buttonTitle,
style: textStyle ??
const TextStyle(
fontSize: 18.0, color: AppColors.secondary),
textAlign: leadingIcon != null ? null : TextAlign.center,
),
),
),
if (trailingIcon != null) ...[trailingIcon],
],
),
);
}