I am creating my custom widget in which I am using RaisedButton
I want to export onTap
event from RaisedButton
to parent widget. How can I do that?
Create a custom widget:
class MyCustomWidget extends StatelessWidget {
final String text;
final VoidCallback? onTap;
const MyCustomWidget(this.text, {
Key? key,
this.onTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: onTap,
child: Text(text),
);
}
}
Usage:
MyCustomWidget(
'My button',
onTap: () {},
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With