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: onTap,
  29. child: Container(
  30. padding: EdgeInsets.all(12),
  31. decoration: BoxDecoration(
  32. border: Border(
  33. top: isTopBorder
  34. ? BorderSide(color: AppColors.GRAY1, width: 0.35)
  35. : BorderSide.none,
  36. bottom: isBottomBorder
  37. ? BorderSide(color: AppColors.GRAY1, width: 0.35)
  38. : BorderSide.none)),
  39. width: double.infinity,
  40. child: Row(
  41. mainAxisSize: MainAxisSize.max,
  42. children: [
  43. leadingIcon == null
  44. ? SizedBox()
  45. : SizedBox(
  46. width: 20,
  47. height: 20,
  48. child: SvgPicture.asset(leadingIcon)),
  49. SizedBox(width: 4),
  50. Expanded(
  51. child: Column(
  52. crossAxisAlignment: CrossAxisAlignment.start,
  53. mainAxisSize: MainAxisSize.min,
  54. children: [
  55. Text(
  56. title,
  57. style: titleStyle ??
  58. 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. }