如何设置 OutlineButton 宽度 > 子宽度和边框扩展到所有可用空间?

阮山

我有一个这样的自定义按钮:

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: () {},
          ),

当我尝试设置宽度 < 子宽度时,左右边框变得更近,里面的文本被扩展为 2 行。但是当我尝试设置宽度>子宽度时,按钮两侧有未使用的空间,当我设置宽度=子宽度时边框仍然保持不变。

有什么方法可以设置宽度> 子宽度并且按钮边框扩展到所有可用空间?

阮山

这实际上是一个错误,遇到此问题的任何人请使用 flutter > v0.5.8-pre.141​​ 切换到主频道

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章