calcolatrice/lib/widgets/custom_button.dart

34 lines
No EOL
920 B
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class CustomButton extends StatelessWidget {
final String label;
final VoidCallback onPressed;
final Color? color;
final Color? textColor;
const CustomButton({
super.key,
required this.label,
required this.onPressed,
this.color,
this.textColor,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: color ?? Colors.grey[200],
foregroundColor: textColor ?? Colors.black,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
),
onPressed: () {
HapticFeedback.lightImpact(); // Feedback tattile al tocco
onPressed();
},
child: Text(label, style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
);
}
}