Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

69 rindas
1.7 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:qadirneyriz/config/config.dart';
  3. // ignore: must_be_immutable
  4. class CustomButton extends StatelessWidget {
  5. CustomButton({
  6. super.key,
  7. this.onPressed,
  8. required this.hieght,
  9. this.fontSize = 16,
  10. this.width,
  11. this.isCircle = false,
  12. this.color,
  13. this.borderRadius = 20,
  14. this.fontWeight,
  15. this.gradient,
  16. this.textColor = Colors.white,
  17. required this.text,
  18. });
  19. double? width;
  20. double hieght;
  21. String text;
  22. bool isCircle;
  23. final Gradient? gradient;
  24. final double borderRadius;
  25. double? fontSize;
  26. Color? color;
  27. Color textColor;
  28. FontWeight? fontWeight;
  29. void Function()? onPressed;
  30. @override
  31. Widget build(BuildContext context) {
  32. return Container(
  33. width: width,
  34. height: hieght,
  35. decoration: BoxDecoration(
  36. gradient: gradient,
  37. borderRadius: isCircle
  38. ? null // اگر دکمه دایره باشد، از borderRadius استفاده نمی‌شود
  39. : BorderRadius.circular(borderRadius),
  40. ),
  41. child: ElevatedButton(
  42. onPressed: onPressed,
  43. style: ElevatedButton.styleFrom(
  44. backgroundColor: gradient == null
  45. ? color ?? config.ui.mainGreen
  46. : Colors.transparent,
  47. shadowColor: (gradient != null) ? Colors.transparent : null,
  48. shape: isCircle == false
  49. ? RoundedRectangleBorder(
  50. borderRadius: BorderRadius.circular(borderRadius),
  51. )
  52. : const CircleBorder(),
  53. ),
  54. child: Text(
  55. text,
  56. style: TextStyle(
  57. fontSize: fontSize,
  58. fontWeight: fontWeight,
  59. color: textColor,
  60. ),
  61. ),
  62. ),
  63. );
  64. }
  65. }