我是新来的翩翩起舞和建立自定义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%的父宽展开?
用double.infinity
有集装箱
把RaisedButton包在ButtonTheme里面,并指定minWidth。
ButtonTheme(
minWidth: double.infinty, //takes up all the width
child: RaisedButton(),
)