I'm currently creating an application and there's a lot of button that is needed. Is there a proper way to create it?
I tried creating class for it but I've encountered multiple errors while creating it specifically in the Material Page Route part.
You can use this class anywhere in your application by creating a custom class.
I think a class like this will work for you.
class CustomButton extends StatelessWidget {
const CustomButton({super.key, required this.child, required
this.onPressed});
final Widget child;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
return MaterialButton(
onPressed: onPressed,
child: child,
);
}
}
You can also use it this way:
CustomButton(
child: const Text('text'),
onPressed: () {},
),