要在下面的代码中使自定义FlatButton的边框更粗,可以通过修改按钮的样式来实现。具体步骤如下:
import 'package:flutter/material.dart';
class CustomFlatButton extends FlatButton {
CustomFlatButton({
Key key,
@required VoidCallback onPressed,
ValueChanged<bool> onHighlightChanged,
ButtonTextTheme textTheme,
Color textColor,
Color disabledTextColor,
Color color,
Color disabledColor,
Color highlightColor,
Color splashColor,
Brightness colorBrightness,
EdgeInsetsGeometry padding,
ShapeBorder shape,
Clip clipBehavior = Clip.none,
FocusNode focusNode,
bool autofocus = false,
MaterialTapTargetSize materialTapTargetSize,
@required Widget child,
}) : super(
key: key,
onPressed: onPressed,
onHighlightChanged: onHighlightChanged,
textTheme: textTheme,
textColor: textColor,
disabledTextColor: disabledTextColor,
color: color,
disabledColor: disabledColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorBrightness: colorBrightness,
padding: padding,
shape: shape,
clipBehavior: clipBehavior,
focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
child: child,
);
}
class CustomFlatButton extends FlatButton {
// ...
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black, // 设置边框颜色
width: 2.0, // 设置边框宽度
),
borderRadius: BorderRadius.circular(8.0), // 设置边框圆角
),
child: super.build(context),
);
}
}
CustomFlatButton(
onPressed: () {
// 按钮点击事件处理
},
child: Text('按钮'),
),
通过以上步骤,我们可以在自定义FlatButton的边框中设置更粗的边框。在示例代码中,我们使用Container来包裹FlatButton,并设置Container的decoration属性来定义边框样式。其中,我们通过Border.all来设置边框的颜色和宽度,通过BorderRadius.circular来设置边框的圆角。最后,将FlatButton的child作为Container的child返回即可。
推荐的腾讯云相关产品:腾讯云云服务器(CVM),产品介绍链接地址:https://cloud.tencent.com/product/cvm
领取专属 10元无门槛券
手把手带您无忧上云