uWrap function

Widget uWrap(
  1. Widget child, {
  2. BorderRadius? borderRadius,
  3. double? radius,
  4. GestureTapCallback? onTap,
  5. VoidCallback? onPress,
  6. GestureTapCallback? onDoubleTap,
  7. GestureLongPressCallback? onLongPress,
  8. GestureTapDownCallback? onTapDown,
  9. GestureTapUpCallback? onTapUp,
  10. GestureTapCancelCallback? onTapCancel,
  11. GestureTapCallback? onSecondaryTap,
  12. HitTestBehavior? hitTestBehavior,
  13. bool splash = false,
  14. Color? splashColor,
  15. Color? highlightColor,
  16. Color? hoverColor,
  17. double? pressedScale,
  18. Duration pressDuration = const Duration(milliseconds: 120),
  19. bool enableFeedback = true,
  20. MouseCursor? cursor,
  21. ValueChanged<bool>? onHover,
  22. double? opacity,
  23. String? tooltip,
  24. String? heroTag,
  25. EdgeInsetsGeometry? margin,
  26. String? semanticsLabel,
  27. bool? semanticsButton,
  28. bool visible = true,
  29. BoxFit? fit,
  30. AlignmentGeometry fitAlignment = Alignment.center,
  31. double? scale,
  32. double? rotate,
  33. Offset? translate,
  34. bool center = false,
  35. bool safeArea = false,
  36. Axis? scrollable,
  37. ScrollController? scrollController,
  38. TextDirection? textDirection,
  39. int? expanded,
  40. int? flexible,
  41. bool positioned = false,
  42. double? left,
  43. double? top,
  44. double? right,
  45. double? bottom,
  46. double? positionedWidth,
  47. double? positionedHeight,
})

Adds u's box, tap, hover, tooltip, hero, fit, transform and position options to any widget (what every U-widget uses). uWrap(Text("Hi"), onTap: open, tooltip: "Open")

Implementation

Widget uWrap(
  Widget child, {
  BorderRadius? borderRadius,
  double? radius,
  GestureTapCallback? onTap,
  VoidCallback? onPress,
  GestureTapCallback? onDoubleTap,
  GestureLongPressCallback? onLongPress,
  GestureTapDownCallback? onTapDown,
  GestureTapUpCallback? onTapUp,
  GestureTapCancelCallback? onTapCancel,
  GestureTapCallback? onSecondaryTap,
  HitTestBehavior? hitTestBehavior,
  bool splash = false,
  Color? splashColor,
  Color? highlightColor,
  Color? hoverColor,
  double? pressedScale,
  Duration pressDuration = const Duration(milliseconds: 120),
  bool enableFeedback = true,
  MouseCursor? cursor,
  ValueChanged<bool>? onHover,
  double? opacity,
  String? tooltip,
  String? heroTag,
  EdgeInsetsGeometry? margin,
  String? semanticsLabel,
  bool? semanticsButton,
  bool visible = true,
  BoxFit? fit,
  AlignmentGeometry fitAlignment = Alignment.center,
  double? scale,
  double? rotate,
  Offset? translate,
  bool center = false,
  bool safeArea = false,
  Axis? scrollable,
  ScrollController? scrollController,
  TextDirection? textDirection,
  int? expanded,
  int? flexible,
  bool positioned = false,
  double? left,
  double? top,
  double? right,
  double? bottom,
  double? positionedWidth,
  double? positionedHeight,
}) {
  if (!visible) return const SizedBox.shrink();
  final GestureTapCallback? effectiveTap = onTap ?? onPress;
  final double? effectivePressedScale = pressedScale ?? (onPress != null ? 0.9 : null);
  Widget current = _uInteractive(
    child,
    radius: _uRadius(borderRadius, radius),
    onTap: effectiveTap,
    onDoubleTap: onDoubleTap,
    onLongPress: onLongPress,
    onTapDown: onTapDown,
    onTapUp: onTapUp,
    onTapCancel: onTapCancel,
    onSecondaryTap: onSecondaryTap,
    hitTestBehavior: hitTestBehavior,
    splash: splash,
    splashColor: splashColor,
    highlightColor: highlightColor,
    hoverColor: hoverColor,
    pressedScale: effectivePressedScale,
    pressDuration: pressDuration,
    enableFeedback: enableFeedback,
    cursor: cursor,
    onHover: onHover,
  );
  current = _uEffects(current, opacity: opacity, tooltip: tooltip, heroTag: heroTag, margin: margin, semanticsLabel: semanticsLabel, semanticsButton: semanticsButton);
  current = _uModifiers(
    current,
    fit: fit,
    fitAlignment: fitAlignment,
    scale: scale,
    rotate: rotate,
    translate: translate,
    center: center,
    safeArea: safeArea,
    scrollable: scrollable,
    scrollController: scrollController,
    textDirection: textDirection,
    expanded: expanded,
    flexible: flexible,
    positioned: positioned,
    left: left,
    top: top,
    right: right,
    bottom: bottom,
    positionedWidth: positionedWidth,
    positionedHeight: positionedHeight,
  );
  return current;
}