Reputation: 2206
How do create a custom widget that extends an already existing widget so it has the same parameters but with some different defaults?
class CustomRaisedButton extends RaisedButton {
final ShapeBorder shape;
final double elevation;
CutstomRaisedButton({this.shape = RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)), this.elevation = 16})
}
Upvotes: 0
Views: 361
Reputation:
Should should create a custom stateless widget that returns your desired button. Pass along an 'OnPressed' function so you can handle the button press on the main page!
class CustomRaisedButton extends StatelessWidget {
CustomRaisedButton({this.onPressed});
final Function onPressed;
@override
Widget build(BuildContext context) {
return RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
elevation: 16,
onPressed: onPressed,
);
}
}
Upvotes: 1