MongolTooltip class

A Mongol material design tooltip.

Tooltips provide text labels which help explain the function of a button or other user interface action. Wrap the button in a Tooltip widget and provide a message which will be shown when the widget is long pressed.

Many widgets, such as IconButton, FloatingActionButton, and MongolPopupMenuButton have a tooltip property that, when non-null, causes the widget to include a Tooltip in its build.

Tooltips improve the accessibility of visual widgets by proving a textual representation of the widget, which, for example, can be vocalized by a screen reader.

{@tool dartpad --template=stateless_widget_scaffold_center}

This example show a basic MongolTooltip which has a MongolText as child. message contains your label to be shown by the tooltip when the child that MongolTooltip wraps is hovered over on web or desktop. On mobile, the tooltip is shown when the widget is long pressed.

Widget build(BuildContext context) {
  return const MongolTooltip(
    message: 'I am a Tooltip',
    child: MongolText('Hover over the text to show a tooltip.'),
  );
}

{@end-tool}

{@tool dartpad --template=stateless_widget_scaffold_center}

This example covers most of the attributes available in MongolTooltip. decoration has been used to give a gradient and borderRadius to MongolTooltip. width has been used to set a specific width of the MongolTooltip. preferRight is false, the tooltip will prefer showing left of MongolTooltip's child widget. However, it may show the tooltip to the right if there's not enough space to the left of the widget. textStyle has been used to set the font size of the 'message'. showDuration accepts a Duration to continue showing the message after the long press has been released. waitDuration accepts a Duration for which a mouse pointer has to hover over the child widget before the tooltip is shown.

Widget build(BuildContext context) {
  return MongolTooltip(
    message: 'I am a Tooltip',
    child: const Text('Tap this text and hold down to show a tooltip.'),
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(25),
      gradient: const LinearGradient(colors: <Color>[Colors.amber, Colors.red]),
    ),
    width: 50,
    padding: const EdgeInsets.all(8.0),
    preferRight: false,
    textStyle: const TextStyle(
      fontSize: 24,
    ),
    showDuration: const Duration(seconds: 2),
    waitDuration: const Duration(seconds: 1),
  );
}

{@end-tool}

See also:

Inheritance

Constructors

MongolTooltip({Key? key, required String message, double? width, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, double? horizontalOffset, bool? preferRight, bool? excludeFromSemantics, Decoration? decoration, TextStyle? textStyle, Duration? waitDuration, Duration? showDuration, Widget? child})
Creates a Mongol tooltip.
const

Properties

child Widget?
The widget below this widget in the tree.
final
decoration Decoration?
Specifies the tooltip's shape and background color.
final
excludeFromSemantics bool?
Whether the tooltip's message should be excluded from the semantics tree.
final
hashCode int
The hash code for this object.
no setterinherited
horizontalOffset double?
The horizontal gap between the widget and the displayed tooltip.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
margin EdgeInsetsGeometry?
The empty space that surrounds the tooltip.
final
message String
The text to display in the tooltip.
final
padding EdgeInsetsGeometry?
The amount of space by which to inset the tooltip's child.
final
preferRight bool?
Whether the tooltip defaults to being displayed to the right of the widget.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showDuration Duration?
The length of time that the tooltip will be shown after a long press is released.
final
textStyle TextStyle?
The style to use for the message of the tooltip.
final
waitDuration Duration?
The length of time that a pointer must hover over a tooltip's widget before the tooltip will be shown.
final
width double?
The width of the tooltip's child.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<MongolTooltip>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited