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());
          },
          hitTestBehavior: HitTestBehavior.translucent,
          child: widget.child);
      break;

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

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

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