df_tooltip 0.0.1 copy "df_tooltip: ^0.0.1" to clipboard
df_tooltip: ^0.0.1 copied to clipboard

Customizable Flutter tooltip widget that automatically adjusts its position based on available space

DFTooltip #

A highly customizable and intelligent Flutter tooltip widget that automatically adjusts its position based on available space. Perfect for displaying contextual information without cluttering your UI.

๐ŸŽฏ Features #

  • Smart Positioning: Automatically adjusts tooltip position based on available screen space
  • Multiple Directions: Support for up, down, left, and right positioning
  • Auto-hide on Scroll: Intelligently hides when user scrolls, perfect for scrollable content
  • Customizable Appearance: Full control over colors, border radius, and dimensions
  • Flexible Sizing: Different width options for vertical vs horizontal tooltips
  • Auto-dismiss: Optional auto-hide with customizable duration
  • Tap to Dismiss: Click anywhere outside to hide the tooltip
  • Overflow Protection: Ensures tooltips never go off-screen

Screenshots #

Feature Screenshot
Basic Tooltip Bottom [Basic Tooltip Bottom]
Different Directions - Right [Directions]
Changes position if there is no space [Changes position if there is no space]
Styling [Styling]

๐Ÿ“ฆ Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  df_tooltip: ^0.0.1

Then run:

flutter pub get

๐Ÿš€ Getting Started #

Import the package in your Dart file:

import 'package:df_tooltip/df_tooltip.dart';

๐Ÿ’ก Usage #

Basic Example #

DFTooltip(
  content: Text(
    'This is a tooltip!',
    style: TextStyle(color: Colors.white),
  ),
  child: ElevatedButton(
    onPressed: () {},
    child: Text('Hover me'),
  ),
)

Advanced Example with Custom Styling #

DFTooltip(
  content: Container(
    padding: EdgeInsets.all(8),
    child: Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Icon(Icons.info, color: Colors.white),
        SizedBox(height: 4),
        Text(
          'Custom styled tooltip with icon',
          style: TextStyle(color: Colors.white),
        ),
      ],
    ),
  ),
  preferredDirection: TooltipDirection.up,
  bgColor: Colors.blue.withOpacity(0.9),
  borderRadius: BorderRadius.circular(12),
  margin: 8.0,
  duration: Duration(seconds: 3),
  sideTooltipWidth: 200,
  child: IconButton(
    icon: Icon(Icons.help_outline),
    onPressed: () {},
  ),
)

In a Scrollable List #

ListView.builder(
  itemCount: 20,
  itemBuilder: (context, index) {
    return ListTile(
      title: Text('Item $index'),
      trailing: DFTooltip(
        content: Text(
          'This tooltip will auto-hide when you scroll!',
          style: TextStyle(color: Colors.white),
        ),
        preferredDirection: TooltipDirection.left,
        child: Icon(Icons.info_outline),
      ),
    );
  },
)

๐Ÿ”ง Customization Options #

Constructor Parameters #

Parameter Type Default Description
child Widget required The widget that triggers the tooltip
content Widget required The content displayed inside the tooltip
preferredDirection TooltipDirection TooltipDirection.up Preferred direction (auto-adjusts if no space)
showOnTap bool true Whether to show tooltip on tap
duration Duration? null Auto-hide duration (null = manual hide only)
margin double 0.0 Space between tooltip and target widget
sideTooltipWidth double? null Custom width for left/right tooltips
upnDownTooltipWidth double? null Custom width for up/down tooltips
bgColor Color? Color(0xCC000000) Background color of the tooltip
borderRadius BorderRadius? BorderRadius.circular(8) Border radius of the tooltip

Tooltip Directions #

enum TooltipDirection {
  up,     // Tooltip appears above the target
  down,   // Tooltip appears below the target
  left,   // Tooltip appears to the left of the target
  right,  // Tooltip appears to the right of the target
}

๐ŸŽจ Styling Examples #

Dark Theme Tooltip #

DFTooltip(
  bgColor: Colors.grey[900],
  borderRadius: BorderRadius.circular(4),
  content: Text('Dark tooltip', style: TextStyle(color: Colors.white)),
  child: YourWidget(),
)

Colorful Tooltip #

DFTooltip(
  bgColor: Colors.purple.withOpacity(0.9),
  borderRadius: BorderRadius.circular(16),
  content: Text('Purple tooltip!', style: TextStyle(color: Colors.white)),
  child: YourWidget(),
)

Large Tooltip for Detailed Content #

DFTooltip(
  sideTooltipWidth: 300,
  upnDownTooltipWidth: 400,
  bgColor: Colors.white,
  borderRadius: BorderRadius.circular(12),
  content: Container(
    padding: EdgeInsets.all(16),
    child: Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text('Detailed Information', 
             style: TextStyle(fontWeight: FontWeight.bold)),
        SizedBox(height: 8),
        Text('This tooltip contains more detailed information...'),
      ],
    ),
  ),
  child: YourWidget(),
)

๐Ÿ“ฑ Platform Support #

  • โœ… Android
  • โœ… iOS
  • โœ… Web
  • โœ… macOS
  • โœ… Windows
  • โœ… Linux

๐Ÿงช Example Project #

Check out the /example folder for a complete working example that demonstrates all features of DFTooltip.

cd example
flutter run

๐Ÿ› Issues and Feedback #

If you encounter any issues or have suggestions for improvements:

  1. Check the existing issues
  2. Create a new issue with detailed information
  3. Include:
    • Flutter version
    • Dart version
    • Device/Platform information
    • Code snippet that reproduces the issue

๐Ÿค Contributing #

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments #

  • Thanks to the Flutter team for the amazing framework
  • Inspired by various tooltip implementations in the Flutter community

Made with โค๏ธ by DartForce22

1
likes
140
points
13
downloads

Publisher

verified publisherdartforce.dev

Weekly Downloads

Customizable Flutter tooltip widget that automatically adjusts its position based on available space

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, provider

More

Packages that depend on df_tooltip