button_cancel.dart 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import 'package:flutter/material.dart';
  2. class CancelButton extends StatelessWidget {
  3. final VoidCallback callback;
  4. final String content;
  5. final double width;
  6. final double height;
  7. final double fontSize;
  8. final Color backgroundColor;
  9. final Color textColor;
  10. final Key? key;
  11. CancelButton({
  12. required this.callback,
  13. required this.content,
  14. this.backgroundColor = const Color(0xffF1F1F1),
  15. this.textColor = const Color(0xff666666),
  16. this.width = double.infinity,
  17. this.height = 35,
  18. this.fontSize = 28, this.key,
  19. });
  20. @override
  21. Widget build(BuildContext context) {
  22. return Container(
  23. width: width,
  24. height: height,
  25. child: TextButton(
  26. onPressed: this.callback,
  27. style: ButtonStyle(
  28. padding: MaterialStateProperty.all(EdgeInsets.zero),
  29. backgroundColor: MaterialStateProperty.all(backgroundColor),
  30. overlayColor: MaterialStateProperty.all(const Color(0xffD1D1D1)),
  31. shape: MaterialStateProperty.all(StadiumBorder())),
  32. child: Text(
  33. "$content",
  34. style: Theme.of(context).textTheme.bodyText2?.copyWith(color: textColor),
  35. ),
  36. ),
  37. );
  38. }
  39. }
  40. class FeelCancelButton extends StatelessWidget {
  41. final VoidCallback callback;
  42. final String content;
  43. final double width;
  44. final double height;
  45. final double fontSize;
  46. final Color color;
  47. final Color borderColor;
  48. final Color textColor;
  49. static const finalColor = Color(0xffffffff);
  50. static const finalBorderColor = Color(0xFFFFC400);
  51. static const finalTextColor = Color(0xFFFFC400);
  52. FeelCancelButton({required this.callback, required this.content, this.width = double.infinity, this.height = 44, this.fontSize = 28, this.color = finalColor, this.textColor = finalTextColor, this.borderColor = finalBorderColor});
  53. @override
  54. Widget build(BuildContext context) {
  55. return InkWell(
  56. onTap: this.callback,
  57. child: Container(
  58. width: width,
  59. height: height,
  60. decoration: BoxDecoration(
  61. color: color,
  62. borderRadius: BorderRadius.all(Radius.circular(100)),
  63. border: Border.all(
  64. color: finalBorderColor,
  65. width: .5,
  66. ),
  67. ),
  68. child: Container(
  69. alignment: Alignment.center,
  70. child: Text(
  71. content,
  72. style: TextStyle(color: textColor, fontSize: 14),
  73. ),
  74. ),
  75. ),
  76. );
  77. }
  78. }