You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.7KB

  1. import 'package:flutter/material.dart';
  2. import '../../../themes/app_dimension.dart';
  3. import '../../../themes/app_colors.dart';
  4. import '../../../themes/styles_text.dart';
  5. class PrimaryButtonWidget extends StatelessWidget {
  6. final String title;
  7. final double width;
  8. final double? height;
  9. final bool isEnable;
  10. final VoidCallback? onPressed;
  11. final Color? color;
  12. final Color? titleColor;
  13. const PrimaryButtonWidget({
  14. required this.title,
  15. this.onPressed,
  16. this.width = double.infinity,
  17. this.isEnable = true,
  18. this.color,
  19. this.height,
  20. this.titleColor,
  21. });
  22. @override
  23. Widget build(BuildContext context) {
  24. return SizedBox(
  25. width: width,
  26. height: height ?? 45.h,
  27. child: ElevatedButton(
  28. onPressed: isEnable ? onPressed : null,
  29. style: ButtonStyle(
  30. backgroundColor: MaterialStateProperty.resolveWith(
  31. (states) {
  32. if (states.contains(MaterialState.disabled)) {
  33. return AppColors.neutral4;
  34. }
  35. return color ?? AppColors.primary1;
  36. },
  37. ),
  38. shadowColor: MaterialStateProperty.resolveWith(
  39. (states) {
  40. return Colors.transparent;
  41. },
  42. ),
  43. overlayColor: MaterialStateProperty.resolveWith(
  44. (states) {
  45. return Colors.transparent;
  46. },
  47. ),
  48. shape: MaterialStateProperty.all<RoundedRectangleBorder>(
  49. RoundedRectangleBorder(
  50. borderRadius: BorderRadius.circular(12.0),
  51. ),
  52. ),
  53. ),
  54. child: Text(
  55. title,
  56. style: StylesText.body5.copyWith(
  57. color: titleColor ?? AppColors.white,
  58. ),
  59. ),
  60. ),
  61. );
  62. }
  63. }