button.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'package:flutter/material.dart';
  2. class MyButton extends StatelessWidget {
  3. final String text;
  4. final VoidCallback? onTap;
  5. final Gradient? gradient;
  6. final double radius;
  7. final Color? backgroundColor;
  8. final double? width;
  9. final double? minWidth;
  10. final double? height;
  11. final double? minHeight;
  12. final double fountSize;
  13. final Color? fountColor;
  14. final FontWeight? fontWeight;
  15. final EdgeInsetsGeometry? padding;
  16. final EdgeInsetsGeometry? margin;
  17. final AlignmentGeometry? alignment;
  18. const MyButton(
  19. this.text, {
  20. Key? key,
  21. this.backgroundColor = const Color(0xFF25A6EE),
  22. this.gradient,
  23. this.radius = 100,
  24. this.width,
  25. this.minWidth,
  26. this.height,
  27. this.minHeight,
  28. this.onTap,
  29. this.fountSize = 14,
  30. this.fountColor = Colors.white,
  31. this.fontWeight,
  32. this.margin,
  33. this.padding = const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
  34. this.alignment = Alignment.center,
  35. }) : super(key: key);
  36. @override
  37. Widget build(BuildContext context) {
  38. return GestureDetector(
  39. onTap: onTap,
  40. child: Container(
  41. width: width,
  42. height: height,
  43. constraints: BoxConstraints(minWidth: minWidth ?? 0, minHeight: minHeight ?? 0),
  44. padding: padding,
  45. margin: margin,
  46. alignment: alignment,
  47. decoration: BoxDecoration(
  48. gradient: gradient,
  49. borderRadius: BorderRadius.all(Radius.circular(radius)),
  50. color: backgroundColor,
  51. ),
  52. child: Text(
  53. text,
  54. style: TextStyle(fontSize: fountSize, color: fountColor, fontWeight: fontWeight),
  55. ),
  56. ),
  57. );
  58. }
  59. }