我有一个这样的自定义按钮:
class ControlButton extends StatelessWidget {
final String text;
final void Function() onPressed;
final double width;
final double height;
ControlButton({
@required this.text,
@required this.onPressed,
this.width = 90.0,
this.height = 40.0,
});
@override
Widget build(BuildContext context) {
return SizedBox(
width: width,
height: height,
child: OutlineButton(
borderSide: BorderSide(color: _orangeColor),
onPressed: onPressed,
child: Text(
text,
style: TextStyle(color: _orangeColor),
),
),
);
}
}
并使用此按钮,如下所示:
ControlButton(
text: 'Hold on',
onPressed: () {},
),
当我尝试设置width <子宽度时,左右边框变得更近,并且内部文本扩展为2行。 但是,当我尝试设置width> child width时,按钮的两侧都有未使用的空间,当我设置width = child width时,边框仍然保持不变。
有什么方法可以设置宽度>子宽度,并且按钮边框可以扩展到所有可用空间吗?
答案 0 :(得分:1)
这实际上是一个错误,任何面对此问题的人请使用flutter> v0.5.8-pre.141切换到主频道