Example #1
0
 public TooltipTheme(
     Key key = null,
     TooltipThemeData data = null,
     Widget child          = null
     ) : base(key: key, child: child)
 {
     D.assert(data != null);
     this.data = data;
 }
Example #2
0
        public override Widget build(BuildContext context)
        {
            D.assert(Overlay.of(context, debugRequiredFor: widget) != null);
            ThemeData        theme        = Theme.of(context);
            TooltipThemeData tooltipTheme = TooltipTheme.of(context);
            TextStyle        defaultTextStyle;
            BoxDecoration    defaultDecoration;

            if (theme.brightness == Brightness.dark)
            {
                defaultTextStyle = theme.textTheme.bodyText2.copyWith(
                    color: Colors.black
                    );
                defaultDecoration = new BoxDecoration(
                    color: Colors.white.withOpacity(0.9f),
                    borderRadius: BorderRadius.all(Radius.circular(4))
                    );
            }
            else
            {
                defaultTextStyle = theme.textTheme.bodyText2.copyWith(
                    color: Colors.white
                    );
                defaultDecoration = new BoxDecoration(
                    color: Colors.grey[700].withOpacity(0.9f),
                    borderRadius: BorderRadius.all(Radius.circular(4))
                    );
            }

            height               = widget.height ?? tooltipTheme?.height ?? _defaultTooltipHeight;
            padding              = widget.padding ?? tooltipTheme?.padding ?? _defaultPadding;
            margin               = widget.margin ?? tooltipTheme?.margin ?? _defaultMargin;
            verticalOffset       = widget.verticalOffset ?? tooltipTheme?.verticalOffset ?? _defaultVerticalOffset;
            preferBelow          = widget.preferBelow ?? tooltipTheme?.preferBelow ?? _defaultPreferBelow;
            excludeFromSemantics = widget.excludeFromSemantics ?? tooltipTheme?.excludeFromSemantics ?? _defaultExcludeFromSemantics;
            decoration           = widget.decoration ?? tooltipTheme?.decoration ?? defaultDecoration;
            textStyle            = widget.textStyle ?? tooltipTheme?.textStyle ?? defaultTextStyle;
            waitDuration         = widget.waitDuration ?? tooltipTheme?.waitDuration ?? _defaultWaitDuration;
            showDuration         = widget.showDuration ?? tooltipTheme?.showDuration ?? _defaultShowDuration;

            Widget result = new GestureDetector(
                behavior: HitTestBehavior.opaque,
                onLongPress: _handleLongPress,
                child: widget.child
                );

            if (_mouseIsConnected)
            {
                result = new MouseRegion(
                    onEnter: (PointerEnterEvent _event) => _showTooltip(),
                    onExit: (PointerExitEvent _event) => _hideTooltip(),
                    child: result
                    );
            }

            return(result);
        }