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.

78 lines
2.4KB

  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: EdgeInsets.all(0),
  28. onPressed: () {
  29. onTap();
  30. },
  31. child: Container(
  32. padding: 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
  42. ? SizedBox()
  43. : SizedBox(
  44. width: 20,
  45. height: 20,
  46. child: SvgPicture.asset(
  47. leadingIcon ?? '',
  48. ),
  49. ),
  50. SizedBox(width: 4),
  51. Expanded(
  52. child: Column(
  53. crossAxisAlignment: CrossAxisAlignment.start,
  54. mainAxisSize: MainAxisSize.min,
  55. children: [
  56. Text(
  57. title ?? '',
  58. style: titleStyle ?? TextStyle(fontSize: 16, fontWeight: FontWeight.w100),
  59. ),
  60. subTitle == null
  61. ? SizedBox()
  62. : Text(
  63. subTitle ?? '',
  64. style: TextStyle(fontSize: 14),
  65. )
  66. ],
  67. ),
  68. ),
  69. trailingIcon == null ? SizedBox() : SvgPicture.asset(trailingIcon ?? '')
  70. ],
  71. ),
  72. ),
  73. ),
  74. );
  75. }
  76. }