dot.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * @Author : WuWei
  3. * @LastEditors : WuWei
  4. * @Date : 2022-11-02 10:26:39
  5. * @LastEditTime : 2022-11-08 11:00:24
  6. * @Description : Do not edit
  7. */
  8. import 'package:flutter/material.dart';
  9. import 'package:wisdom_cli/wisdom_cli.dart';
  10. ///小圆点
  11. class WDot extends StatelessWidget {
  12. const WDot({
  13. Key? key,
  14. this.onTap,
  15. this.child,
  16. this.padding = EdgeInsets.zero,
  17. this.color = Colors.red,
  18. this.textStyle,
  19. this.constraints,
  20. this.iconTheme,
  21. this.behavior = HitTestBehavior.opaque,
  22. }) : super(key: key);
  23. ///右上角删除按钮
  24. WDot.delete({
  25. Key? key,
  26. this.onTap,
  27. this.behavior = HitTestBehavior.opaque,
  28. this.padding = EdgeInsets.zero,
  29. this.color = Colors.black45,
  30. this.textStyle,
  31. this.constraints,
  32. this.iconTheme,
  33. }) : this.child = Icon(Icons.close),
  34. super(key: key);
  35. final HitTestBehavior behavior;
  36. final void Function()? onTap;
  37. final EdgeInsetsGeometry padding;
  38. final Color color;
  39. final BoxConstraints? constraints;
  40. final IconThemeData? iconTheme;
  41. final TextStyle? textStyle;
  42. final Widget? child;
  43. @override
  44. Widget build(BuildContext context) {
  45. Widget current = DefaultTextStyle(
  46. style: TextStyle(
  47. fontSize: 10.pt,
  48. color: Colors.white,
  49. ).merge(textStyle),
  50. child: IconTheme(
  51. data: IconThemeData(
  52. size: 15.pt,
  53. color: Colors.white,
  54. ).merge(iconTheme),
  55. child: Container(
  56. padding: padding,
  57. constraints: constraints,
  58. decoration: BoxDecoration(
  59. color: color,
  60. borderRadius: BorderRadius.circular(1000),
  61. ),
  62. child: child,
  63. ),
  64. ),
  65. );
  66. if (onTap != null) {
  67. current = GestureDetector(
  68. behavior: behavior,
  69. onTap: onTap,
  70. child: current,
  71. );
  72. }
  73. return current;
  74. }
  75. }