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"),
);
}
网友评论