migrate bottom button from stateful to stateless

null_safety
小赖 4 years ago
parent 011b25b5ba
commit 7e1a279cb4

@ -101,6 +101,18 @@ class ASBottomButton extends StatelessWidget {
textColor = kPrimaryColor, textColor = kPrimaryColor,
width = double.infinity, width = double.infinity,
super(key: key); super(key: key);
Widget get _title {
if (title is String)
return Text(
title,
style: textStyle ??
TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.bold,
),
);
return title;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -111,27 +123,21 @@ class ASBottomButton extends StatelessWidget {
gradient: LinearGradient( gradient: LinearGradient(
begin: begin ?? Alignment.bottomRight, begin: begin ?? Alignment.bottomRight,
end: end ?? Alignment.topLeft, end: end ?? Alignment.topLeft,
colors: colors ?? [bgcolor, bgcolor]), colors: colors ?? [bgcolor, bgcolor],
),
), ),
child: MaterialButton( child: MaterialButton(
onPressed: onPressed, onPressed: onPressed,
textColor: textColor ?? kLightTextColor, textColor: textColor ?? kLightTextColor,
disabledColor: disableColor, disabledColor: disableColor,
disabledTextColor: disableTextColor, disabledTextColor: disableTextColor,
padding: padding ?? padding: padding ?? EdgeInsets.symmetric(vertical: 13.w),
EdgeInsets.symmetric(
vertical: 13.w,
),
elevation: 0, elevation: 0,
hoverElevation: 0, hoverElevation: 0,
highlightElevation: 0, highlightElevation: 0,
focusElevation: 0, focusElevation: 0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: title is String child: _title,
? Text(title,
style: textStyle ??
TextStyle(fontSize: 20.sp, fontWeight: FontWeight.bold))
: title,
), ),
); );
} }

Loading…
Cancel
Save