border_select_widget.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:widgets/my_load_image.dart';
  4. import 'package:widgets/my_text_view.dart';
  5. class BorderSelectWidget extends StatelessWidget {
  6. final String text;
  7. final Color color;
  8. final double borderRadius;
  9. final void Function(BuildContext targetContext)? onTap; // 点击事件
  10. const BorderSelectWidget({
  11. Key? key,
  12. required this.text,
  13. required this.color,
  14. this.borderRadius = 15,
  15. this.onTap,
  16. }) : super(key: key);
  17. @override
  18. Widget build(BuildContext context) {
  19. return GestureDetector(
  20. onTap: () {
  21. onTap?.call(context);
  22. },
  23. child: Container(
  24. padding: EdgeInsets.only(left: 8.5, right: 8.5, top: 4, bottom: 4),
  25. decoration: BoxDecoration(
  26. border: Border.all(color: color, width: 0.5), // 边框颜色
  27. borderRadius: BorderRadius.circular(borderRadius), // 圆角
  28. ),
  29. child: Row(
  30. mainAxisSize: MainAxisSize.min, // 使 Row 根据内容大小而收缩
  31. children: [
  32. MyTextView(
  33. text,
  34. textColor: color,
  35. fontSize: 14,
  36. isFontRegular: true,
  37. marginRight: 7,
  38. ),
  39. MyAssetImage(
  40. Assets.baseServiceBorderWidgetDropDown,
  41. color: color,
  42. height: 7.5,
  43. width: 4.5,
  44. ),
  45. ],
  46. ),
  47. ),
  48. );
  49. }
  50. }