flutter - 使自定义 RisedButton 展开
问题描述
我是新来的颤振和构建自定义 RisedButton 我有这个按钮
import 'package:flutter/material.dart';
class EasyButton extends StatelessWidget {
final onPressed;
final text;
EasyButton(this.onPressed, this.text);
@override
Widget build(BuildContext context) {
return RaisedButton(
onPressed: this.onPressed,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(60),
),
padding: EdgeInsets.all(0),
elevation: 2,
splashColor: Colors.blue[300],
child: Ink(
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(60),
gradient: new LinearGradient(
colors: [Colors.blue, Colors.blue[800]],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
padding: EdgeInsets.symmetric(horizontal: 30, vertical: 10),
child: new Text(this.text, style: TextStyle(color: Colors.white)),
),
);
}
}
但是当我将它与扩展小部件一起使用时,我得到了这个结果
如何使其 100% 扩展父宽度?
与双无限
带容器
解决方案
将 RaisedButton 包裹在 ButtonTheme 中并指定 minWidth。
ButtonTheme(
minWidth: double.infinty, //takes up all the width
child: RaisedButton(),
)
推荐阅读
- python - 从二维数组矢量化中获取值
- c# - How to use the C# g4 grammar with antlr in Python?
- angular - 如何在鼠标事件绑定中传递参数
- delphi - 过程调用中的 Tstringlist 与 Tstrings
- python - 列出的列表返回索引值
- r - 如何根据名称文本将多个变量与 R 中的特定模式合并?
- javascript - 在指针事件为 null 的元素上“单击”(或替代方法)
- mysql - ModuleNotFoundError:导入 mysql 时没有名为“_version”的模块
- c# - 在单击 Xamarin.Forms.Maps 时添加图钉
- r - 在 R 中使用 sapply 而不是循环