A lightweight, highly-customizable tooltip widget for Flutter with support for top/bottom positioning, controllers, and rich content.
Quick links
- Widget:
MTooltip— lib/mtooltip.dart - Card helper:
MTooltipCard— lib/mtooltip_card.dart - Shape & alignment:
ToolTipCustomShape,TooltipAlign— lib/tooltip_custom_shape.dart - Positioning delegate:
MTooltipPositionDelegate— lib/mtooltip_position_delegate.dart - Controller API:
MTooltipController, implIMTooltipController— lib/controller/mtooltip_controller.dart
- Custom shape with arrow indicator (top / bottom)
- Attach a controller to programmatically show / remove tooltips
- Accepts any widget as tooltip content (cards, texts, images, etc.)
- Fade-in/out animation and configurable timings
- Example app included: example/lib/main.dart
Installation Add this package to your project's pubspec.yaml:
dependencies:
mtooltip: - Dart SDK: ^3.9.2 (see package pubspec) — pubspec.yaml
- Flutter: >=1.17.0
final controller = MTooltipController();
MTooltip(
context: context,
child: Icon(Icons.info),
tooltipContent: const Text('Simple tooltip content'),
backgroundColor: Colors.blue,
mTooltipController: controller,
);Use the controller to show or remove the tooltip:
controller.show();
controller.remove();Controller API: MTooltipController.show and MTooltipController.remove.
final controller = MTooltipController();
MTooltip(
context: context,
mTooltipController: controller,
tooltipAlign: TooltipAlign.top,
backgroundColor: Colors.black87,
tooltipContent: Container(
child: Column(
children: [
Text("This is a Tooltip"),
IconButton(
onPressed: () {
mc1.remove();
mc2.show();
},
icon: Icon(Icons.navigate_next),
),
]),
),
child: const Text('Tap to show tooltip'),
);See MTooltipCard for the card structure.
- The main widget is
MTooltip. - Alignment choices are provided by
TooltipAlign. - Positioning is computed by
MTooltipPositionDelegate. - Attach a controller using the
mTooltipControllerconstructor parameter; the controller factory isMTooltipController().
- Run the example app in
example/— see example/lib/main.dart. - Run unit tests:
flutter testTests live at test/mtooltip_test.dart.
Contributions are welcome. Please follow standard fork/branch/PR workflow and update or add tests where appropriate.
This project is MIT-licensed — see LICENSE.