build method

  1. @override
Widget build(
  1. BuildContext context
)

Implementation

@override
Widget build(BuildContext context)
{
  // wrap child in detector
  switch (opener)
  {
    // hover
    case OpenMethods.hover:
      view = MouseRegion(onEnter: (_)
        {
          if (timer != null) timer!.cancel();
          showOverlay(context);
        },
        onExit: (_)
        {
          if (timer != null) timer!.cancel();
          timer = Timer(Duration(milliseconds: widget.model.timeout > 0 ? widget.model.timeout : 250), () => hideOverlay());
        },
        child: widget.child, hitTestBehavior: HitTestBehavior.translucent);
      break;

    // tap
    case OpenMethods.tap:
      view = GestureDetector(onTap: () => overlayEntry == null ? showOverlay(context) : hideOverlay(), child: widget.child, behavior: HitTestBehavior.translucent);
      break;

    // long tap
    case OpenMethods.longpress:
      view = GestureDetector(onLongPress: () => overlayEntry == null ? showOverlay(context) : hideOverlay(), child: widget.child, behavior: HitTestBehavior.translucent);
      break;

    // manual
    default:
      view = widget.child;
      break;
  }
  return view;
}