I have a class MyButton
derived from RaisedButton
as follows.
class MyButton extends RaisedButton {
final double height;
MyButton({
String text,
VoidCallback onPressed,
this.height,
}) : super(child: Text(text), onPressed: onPressed);
@override
Widget build(BuildContext context) => SizedBox(
height: height,
child: this,
);
}
I use it in the main
method as follows.
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Hello World'),
),
body: Center(
child: MyButton(text: 'Press Me', height: 80, onPressed: () {}),
),
),
);
}
}
It produces a blank white page with some errors
The following StackOverflowError was thrown building MyButton:
Question
How to wrap the derived RaisedButton
with SizedBox
in its own class?