my_click_item.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import 'package:flutter/material.dart';
  2. import 'package:ftrecruiter/comm/constants/color_constants.dart';
  3. import 'package:ftrecruiter/comm/widget/my_load_image.dart';
  4. // ignore: slash_for_doc_comments
  5. /**
  6. 默认是左边文本图标等 右边more小箭头
  7. 常用于Me页面的跳转
  8. 模板:
  9. MyClickItem(
  10. title: '测试SP-存和取',
  11. drawablePadding: 0,
  12. onTap: () {
  13. SpUtil.putString("username", "Sky24n");
  14. SpUtil.putString(SPConstant.SP_KEY_TOKEN, "1234");
  15. String? userName = SpUtil.getString("username");
  16. if (!TextUtil.isEmpty(userName)) {
  17. SmartDialog.compatible.showToast('username:$userName');
  18. }
  19. },
  20. backgroundColor: ColorConstants.dividerColor,
  21. ),
  22. */
  23. class MyClickItem extends StatelessWidget {
  24. const MyClickItem({
  25. Key? key,
  26. required this.onTap,
  27. required this.title,
  28. this.title_color = Colors.black,
  29. this.title_size = 16,
  30. this.image_path,
  31. this.image_width = 25,
  32. this.image_height = 25,
  33. this.backgroundColor = Colors.white,
  34. this.paddingTop = 8,
  35. this.padingBottom = 8,
  36. this.paddingLeft = 15,
  37. this.paddingRight = 15,
  38. this.marginTop = 0,
  39. this.marginBottom = 0,
  40. this.marginLeft = 0,
  41. this.marginRight = 0,
  42. this.drawablePadding = 10,
  43. this.border_radius = 5.0,
  44. }) : super(key: key);
  45. final Function() onTap;
  46. final String? image_path;
  47. final double? image_width;
  48. final double? image_height;
  49. final String title;
  50. final Color title_color;
  51. final double title_size;
  52. final Color backgroundColor;
  53. final double border_radius;
  54. final double paddingLeft, paddingTop, paddingRight, padingBottom;
  55. final double marginLeft, marginTop, marginRight, marginBottom;
  56. final double drawablePadding;
  57. @override
  58. Widget build(BuildContext context) {
  59. return Container(
  60. margin: EdgeInsets.fromLTRB(marginLeft, marginTop, marginRight, marginBottom),
  61. child: Material(
  62. borderRadius: BorderRadius.circular(border_radius),
  63. color: backgroundColor,
  64. child: InkWell(
  65. onTap: onTap,
  66. customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(11)),
  67. child: Padding(
  68. padding: EdgeInsets.fromLTRB(paddingLeft, paddingTop, paddingRight, padingBottom),
  69. child: Row(
  70. children: [
  71. image_path == null
  72. ? const SizedBox()
  73. : MyLoadImage(
  74. image_path!,
  75. width: image_width,
  76. height: image_height,
  77. ),
  78. SizedBox(
  79. width: drawablePadding,
  80. ),
  81. Expanded(
  82. child: Text(
  83. title,
  84. style: TextStyle(color: title_color, fontSize: title_size),
  85. )),
  86. const Icon(
  87. Icons.chevron_right,
  88. color: ColorConstants.darkGray,
  89. ),
  90. ],
  91. ),
  92. ),
  93. ),
  94. ),
  95. );
  96. }
  97. }