You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
car_common_app/lib/widgets/button/show_fill_button.dart

84 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
class ShowFillButton extends StatelessWidget {
String title;
Color? backgroundColor;
VoidCallback onPressed;
Color txtColor;
double elevation, radius, maxWidth, maxHeight, fontSize, horizontalPadding, horizontalMargin, verticalMargin;
bool isFlatButton, isBold;
EdgeInsets? margin;
bool isFilled;
Color borderColor;
ShowFillButton({
super.key,
required this.title,
required this.onPressed,
this.txtColor = Colors.white,
this.backgroundColor = MyColors.darkPrimaryColor,
this.elevation = 0,
this.isFilled = true,
this.radius = 0,
this.maxWidth = 88,
this.maxHeight = 45,
this.fontSize = 16,
this.horizontalPadding = 16,
this.isFlatButton = false,
this.isBold = true,
this.horizontalMargin = 0,
this.verticalMargin = 0,
this.margin,
this.borderColor = MyColors.primaryColor,
});
@override
Widget build(BuildContext context) {
return isFlatButton
? Container(
height: maxHeight,
padding: const EdgeInsets.only(
left: 20,
right: 20,
),
child: showButton(),
)
: Padding(
padding: margin ?? const EdgeInsets.all(0.0),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: maxHeight,
minWidth: maxWidth,
maxHeight: maxHeight,
maxWidth: maxWidth,
),
child: showButton(),
),
);
}
Widget showButton() {
return Container(
// decoration: isFlatButton ? null : MyColors.gradientButton,
color: isFlatButton ? null : isFilled ? backgroundColor : null,
margin: EdgeInsets.symmetric(horizontal: horizontalMargin, vertical: verticalMargin),
child: MaterialButton(
onPressed: onPressed,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
side: isFilled ? BorderSide.none: BorderSide(width: 2, color: borderColor),
),
child: title.toText(
fontSize: fontSize,
isBold: isBold,
color: txtColor,
maxLines: 1,
),
),
);
}
}