ToolTip Widget
The ToolTip
widget allows you to display contextual information in a small, interactive bubble that appears when users interact with a target widget (e.g., a button). The tooltip can display a message or a custom widget and provides extensive options to control its appearance, behavior, and timing.
Key Properties and Features
- Wrap Target Widgets: The
widget
property allows you to wrap any widget (e.g., a button) in theToolTip
to show tooltip information when users interact with it. - Message: The tooltip can display a simple text message when triggered.
- Trigger Modes: Customize how the tooltip is triggered (e.g., tap, longPress) with the
triggerMode
property. - Timing Customization: Control the delay before the tooltip appears (
waitDuration
) and how long it remains visible (showDuration
). - Positioning: The tooltip can be displayed above or below the target widget, with adjustable vertical offsets for precise placement.
- Style Customization: Customize the tooltip’s text style, background color, border, and padding.
- Actions on Trigger: The
onTriggered
event allows you to run custom actions when the tooltip is triggered.
Properties
Property | Type | Description |
---|---|---|
message | string | The text message to display inside the tooltip. Defaults to an empty string if not provided. |
widget | Widget | The widget (e.g., a button) that the tooltip wraps around to show tooltip information upon interaction. |
textStyle | TextStyle | Defines the text style (font size, color, etc.) for the tooltip’s message. Defaults to system styling. |
verticalOffset | double | The vertical distance between the tooltip and its target widget. Defaults to 0.0 . |
preferBelow | boolean | If true , the tooltip prefers to appear below the target widget. If false , it prefers to appear above. Defaults to true . |
waitDuration | number | The amount of time to wait before showing the tooltip after it’s triggered. Defaults to Duration(milliseconds: 0) . |
showDuration | number | The duration for which the tooltip is visible before automatically disappearing. Defaults to Duration(milliseconds: 1500) . |
triggerMode | string | Specifies how the tooltip is triggered. Acceptable values include TooltipTriggerMode.tap , TooltipTriggerMode.longPress . Defaults to TooltipTriggerMode.tap . |
onTriggered | Action | Action to be executed when the tooltip is triggered. Defaults to null . |
Methods
Method | Description |
---|---|
show() | Programmatically shows the tooltip. |
Getters
Getter | Type | Description |
---|---|---|
isVisible | boolean | Returns true if the tooltip is currently visible. |
Style Properties
Box Styles (Inherited)
This widget also inherits these styles:
Property | Type | Description |
---|---|---|
margin | integer/string | Margin with CSS-style notation (1 to 4 integers) e.g. margin: 5 20 5 |
padding | integer/string | Padding with CSS-style notation (1 to 4 integers) e.g. padding: 5 20 5 |
backgroundColor | Color | The background color of this widget. |
backgroundImage | BackgroundImage | The background image of this widget. |
backgroundGradient | Gradient | The background gradient of this widget. |
border | Border | The border of this widget. |
shadow | Shadow | The shadow of this widget |
clipContent | boolean | Some widgets (such as Image) may bleed through the container when borderRadius is set. Use this to apply a clipping to ensure this does not happen. |
width | integer | The width of this widget. |
height | integer | The height of this widget. |
borderRadius | string or integer | The border radius of the widget. This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0. |
borderColor | integer or string | Sets the border color, starting with '0xFF' for full opacity. Possible values: transparent, black, blue, white, red, grey, teal, amber, pink, purple, yellow, green, brown, cyan, indigo, lime, orange. |
borderWidth | integer | Thickness of the border. Minimum value should be 0. |
shadowColor | integer or string | Sets the box shadow color starting with '0xFF' for full opacity. Possible values: transparent, black, blue, white, red, grey, teal, amber, pink, purple, yellow, green, brown, cyan, indigo, lime, orange. |
shadowOffset | array | The values in the array define the horizontal and vertical offset of the shadow. Example: if the shadowOffset is set to [2, 4], the shadow will be offset by 2 pixels horizontally and 4 pixels vertically from its original position. |
shadowRadius | string or integer | The border radius of the widget. This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0. |
shadowStyle | string | The blur style to apply on the shadow: normal, solid, outer, inner. |
Base Styles (Inherited)
This widget also inherits these base styles:
Property | Type | Description |
---|---|---|
visible | boolean | Toggle a widget visibility on/off. Note that an invisible widget will not occupy UI space, unless the visibilityTransitionDuration is specified. |
visibilityTransitionDuration | number | Specify the duration in seconds when a widget animates between visible and not visible state. Note that setting this value will cause the widget to still occupy the UI space even when it is not visible. |
elevation | integer | The z-coordinate at which to place this material relative to its parent. A non-zero value will show a shadow, with its size relative to the elevation value. (Minimum: 0, Maximum: 24) |
elevationShadowColor | Color | The shadow color for the elevation. |
elevationBorderRadius | integer / string | If the widget has a borderRadius, this should be changed to have the same value. Use with CSS-like notation (1 to 4 integers). |
alignment | Alignment | Align this widget relative to its parent. |
stackPositionTop | integer | The distance of the child's top edge from the top of the stack. This is applicable only for Stack's children. |
stackPositionBottom | integer | The distance that the child's bottom edge from the bottom of the stack. This is applicable only for Stack's children. |
stackPositionLeft | integer | The distance that the child's left edge from the left of the stack. This is applicable only for Stack's children. |
stackPositionRight | integer | The distance that the child's right edge from the right of the stack. This is applicable only for Stack's children. |
captureWebPointer | boolean | Applicable for Web only. When overlaying widgets on top of certain HTML container (e.g., Maps), the mouse click is captured by the HTML container, causing issue interacting with the widget. Use this to capture and maintain the mouse pointer on your widget. |