Flutter 简单自定义一个button
2019-11-25 本文已影响0人
Sinda_Liu
Flutter 构建一个CustomButton,组合RaiseButton和label.
//自定义CustomButton类方法
class CustomButton extends StatelessWidget {
final String label;
CustomButton(this.label);
@override
Widget build(BuildContext context) {
return RaisedButton(onPressed: () {}, child: Text(label));
}
}
//使用CustomButton,在页面中间显示一个“Hello”的按钮
@override
Widget build(BuildContext context) {
return Center(
child: CustomButton("Hello"),
);
}