button.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. final BoxBorder? border;
  19. const MyButton(
  20. this.text, {
  21. Key? key,
  22. this.backgroundColor = const Color(0xFF25A6EE),
  23. this.gradient,
  24. this.radius = 100,
  25. this.width,
  26. this.minWidth,
  27. this.height,
  28. this.minHeight,
  29. this.onTap,
  30. this.fountSize = 14,
  31. this.fountColor = Colors.white,
  32. this.fontWeight,
  33. this.margin,
  34. this.padding = const EdgeInsets.symmetric(vertical: 6, horizontal: 16),
  35. this.alignment = Alignment.center,
  36. this.border,
  37. }) : super(key: key);
  38. @override
  39. Widget build(BuildContext context) {
  40. return GestureDetector(
  41. onTap: onTap,
  42. child: Container(
  43. width: width,
  44. height: height,
  45. constraints: BoxConstraints(minWidth: minWidth ?? 0, minHeight: minHeight ?? 0),
  46. padding: padding,
  47. margin: margin,
  48. alignment: alignment,
  49. decoration: BoxDecoration(
  50. gradient: gradient,
  51. borderRadius: BorderRadius.all(Radius.circular(radius)),
  52. color: backgroundColor,
  53. border: border
  54. ),
  55. child: Text(
  56. text,
  57. style: TextStyle(fontSize: fountSize, color: fountColor, fontWeight: fontWeight),
  58. ),
  59. ),
  60. );
  61. }
  62. }