import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: MyCustomButton(
onValueChanged: (value) {
print("ValueChanged: $value");
},
onCallback: () {
print("Callback function executed");
},
someFunction: (int number) {
print("Function with parameter: $number");
},
),
),
),
);
}
}
class MyCustomButton extends StatelessWidget {
final ValueChanged<int> onValueChanged;
final Function someFunction;
final VoidCallback onCallback;
MyCustomButton({
required this.onValueChanged,
required this.someFunction,
required this.onCallback,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
onValueChanged(42);
someFunction(10);
onCallback();
},
child: Text("Press me"),
);
}
}