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.

70 lines
2.3KB

  1. import 'package:farm_tpf/utils/const_color.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_svg/flutter_svg.dart';
  4. class ButtonIconWidget extends StatelessWidget {
  5. final String title;
  6. final TextStyle? titleStyle;
  7. final String? subTitle;
  8. final Function onTap;
  9. final String? leadingIcon;
  10. final String? trailingIcon;
  11. final bool isTopBorder;
  12. final bool isBottomBorder;
  13. ButtonIconWidget(
  14. {required this.title,
  15. required this.onTap,
  16. this.titleStyle,
  17. this.subTitle,
  18. this.leadingIcon,
  19. this.trailingIcon,
  20. this.isBottomBorder = true,
  21. this.isTopBorder = true});
  22. @override
  23. Widget build(BuildContext context) {
  24. return SizedBox(
  25. width: double.infinity,
  26. child: MaterialButton(
  27. padding: const EdgeInsets.all(0),
  28. onPressed: () {
  29. onTap();
  30. },
  31. child: Container(
  32. padding: const EdgeInsets.all(12),
  33. decoration: BoxDecoration(
  34. border: Border(
  35. top: isTopBorder ? BorderSide(color: AppColors.GRAY1, width: 0.35) : BorderSide.none,
  36. bottom: isBottomBorder ? BorderSide(color: AppColors.GRAY1, width: 0.35) : BorderSide.none)),
  37. width: double.infinity,
  38. child: Row(
  39. mainAxisSize: MainAxisSize.max,
  40. children: [
  41. leadingIcon == null ? const SizedBox() : SizedBox(width: 20, height: 20, child: SvgPicture.asset(leadingIcon)),
  42. const SizedBox(width: 4),
  43. Expanded(
  44. child: Column(
  45. crossAxisAlignment: CrossAxisAlignment.start,
  46. mainAxisSize: MainAxisSize.min,
  47. children: [
  48. Text(
  49. title,
  50. style: titleStyle ?? const TextStyle(fontSize: 16, fontWeight: FontWeight.w100),
  51. ),
  52. subTitle == null
  53. ? const SizedBox()
  54. : Text(
  55. subTitle ?? '',
  56. style: const TextStyle(fontSize: 14),
  57. )
  58. ],
  59. ),
  60. ),
  61. trailingIcon == null ? const SizedBox() : SvgPicture.asset(trailingIcon)
  62. ],
  63. ),
  64. ),
  65. ),
  66. );
  67. }
  68. }