rounded_button.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import 'package:flutter/material.dart';
  2. class RoundedButton extends StatelessWidget {
  3. final VoidCallback? press;
  4. final String? title;
  5. final double? width;
  6. final double? height;
  7. final BorderRadius borderRadius;
  8. final Color borderColor;
  9. final Color color;
  10. final Color textColor;
  11. const RoundedButton({
  12. Key? key,
  13. this.press,
  14. this.title,
  15. this.width,
  16. this.height,
  17. this.borderRadius = BorderRadius.zero,
  18. this.borderColor = Colors.transparent,
  19. this.color = Colors.transparent,
  20. this.textColor = Colors.white,
  21. }) : super(key: key);
  22. @override
  23. Widget build(BuildContext context) {
  24. return ConstrainedBox(
  25. constraints: BoxConstraints(
  26. minWidth: 100,
  27. maxWidth: width ?? double.infinity,
  28. minHeight: 50,
  29. maxHeight: height ?? 60,
  30. ),
  31. child: Container(
  32. margin: const EdgeInsets.symmetric(vertical: 10),
  33. decoration: BoxDecoration(
  34. border: Border.all(color: borderColor),
  35. borderRadius: borderRadius,
  36. color: color,
  37. ),
  38. child: SizedBox.expand(
  39. child: TextButton(
  40. child: Text(title ?? '', style: TextStyle(color: textColor)),
  41. onPressed: press,
  42. ),
  43. ),
  44. ),
  45. );
  46. }
  47. }