### Auto-Positioning Tooltip Example Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Let the tooltip automatically choose the best position. This example uses the 'auto' preferred direction. ```dart SuperTooltip( controller: _controller, positionConfig: const PositionConfiguration( preferredDirection: TooltipDirection.auto, ), content: const Text( "I automatically position myself!", style: TextStyle(color: Colors.white), ), child: const Icon(Icons.help), ) ``` -------------------------------- ### Custom Styled Tooltip Example Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Create a visually distinct tooltip with custom styling for background, border, shadow, and arrow. This example demonstrates error styling. ```dart SuperTooltip( controller: _controller, style: TooltipStyle( backgroundColor: Colors.red, borderColor: Colors.redAccent, borderWidth: 3.0, borderRadius: 15.0, hasShadow: true, shadowColor: Colors.red.withOpacity(0.3), shadowBlurRadius: 20.0, ), arrowConfig: const ArrowConfiguration( length: 15.0, baseWidth: 25.0, ), content: const Padding( padding: EdgeInsets.all(12.0), child: Text( "Error: Something went wrong!", style: TextStyle(color: Colors.white), ), ), child: const Icon(Icons.error, color: Colors.red), ) ``` -------------------------------- ### Hover Tooltip (Web/Desktop) Example Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Show a tooltip on hover with automatic dismissal. This configuration is suitable for web and desktop applications. ```dart SuperTooltip( controller: _controller, interactionConfig: const InteractionConfiguration( showOnHover: true, hideOnHoverExit: true, ), animationConfig: const AnimationConfiguration( waitDuration: Duration(milliseconds: 500), ), content: const Text( "Hover tooltip!", style: TextStyle(color: Colors.white), ), child: const Icon(Icons.info), ) ``` -------------------------------- ### Import Super Tooltip Package Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Import the SuperTooltip widget into your Dart code to start using it. ```dart import 'package:super_tooltip/super_tooltip.dart'; ``` -------------------------------- ### Install Super Tooltip Package Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Add the super_tooltip package to your Flutter project's dependencies. This command updates your pubspec.yaml file. ```bash flutter pub add super_tooltip ``` -------------------------------- ### Touch-Through Areas for Tooltips Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Allow touches to pass through specific areas of the tooltip using `touchThroughArea` and `touchThroughAreaShape`. This is useful for tutorials or guided interactions. ```dart SuperTooltip( controller: _controller, touchThroughArea: Rect.fromLTWH(100, 100, 200, 100), touchThroughAreaShape: ClipAreaShape.rectangle, touchThroughAreaCornerRadius: 10.0, barrierConfig: const BarrierConfiguration(show: true), content: const Text("Tutorial step 1"), child: const Icon(Icons.lightbulb), ) ``` -------------------------------- ### Use Configuration Objects for Tooltip Styling Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Demonstrates the best practice of using configuration objects, specifically TooltipStyle, to group related styling properties for tooltips. This improves code organization and reusability. ```dart // Good final myTooltipStyle = TooltipStyle( backgroundColor: Colors.blue, borderRadius: 10.0, ); SuperTooltip(style: myTooltipStyle, ...) ``` -------------------------------- ### Basic Super Tooltip Usage Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Demonstrates the fundamental implementation of SuperTooltip. Requires a StatefulWidget and a SuperTooltipController to manage the tooltip's visibility. ```dart class MyWidget extends StatefulWidget { @override State createState() => _MyWidgetState(); } class _MyWidgetState extends State { final _controller = SuperTooltipController(); @override Widget build(BuildContext context) { return SuperTooltip( controller: _controller, content: const Text( "This is a simple tooltip!", style: TextStyle(color: Colors.white), ), child: IconButton( icon: const Icon(Icons.info), onPressed: () => _controller.showTooltip(), ), ); } } ``` -------------------------------- ### Migrate from Old API to New Configuration Objects Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Shows the transition from the old SuperTooltip API with flat parameters to the new API utilizing configuration objects for better organization. The new API groups related settings like position, style, and interaction. ```dart SuperTooltip( popupDirection: TooltipDirection.up, backgroundColor: Colors.blue, borderColor: Colors.black, borderWidth: 2.0, showCloseButton: true, closeButtonColor: Colors.white, showBarrier: true, barrierColor: Colors.black54, showOnHover: true, // ... many more parameters ) ``` ```dart SuperTooltip( positionConfig: PositionConfiguration( preferredDirection: TooltipDirection.up, ), style: TooltipStyle( backgroundColor: Colors.blue, borderColor: Colors.black, borderWidth: 2.0, ), closeButtonConfig: CloseButtonConfiguration( show: true, color: Colors.white, ), barrierConfig: BarrierConfiguration( show: true, color: Colors.black54, ), interactionConfig: InteractionConfiguration( showOnHover: true, ), ) ``` -------------------------------- ### Define Reusable App-Wide Tooltip Styles Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Illustrates how to create reusable tooltip styles using static constants within a class. This allows for consistent styling across the application by defining primary and error tooltip styles. ```dart class AppTooltipStyles { static const primary = TooltipStyle( backgroundColor: Colors.blue, borderRadius: 8.0, ); static const error = TooltipStyle( backgroundColor: Colors.red, borderRadius: 8.0, ); } ``` -------------------------------- ### Custom Decoration with DecorationBuilder Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Achieve complete control over the tooltip's appearance by providing a custom `decorationBuilder`. This allows for complex shapes and effects. ```dart SuperTooltip( decorationBuilder: (target) { return ShapeDecoration( color: Colors.blue, shadows: [ BoxShadow( color: Colors.black26, blurRadius: 10, offset: Offset(0, 4), ), ], shape: CustomShape( target: target, // Your custom shape implementation ), ); }, // ... ) ``` -------------------------------- ### Tooltip with Complex Content Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Use this snippet to create tooltips with rich content, including buttons and interactive elements. Ensure the SuperTooltipController is initialized. ```dart SuperTooltip( controller: _controller, style: TooltipStyle( backgroundColor: Colors.white, borderColor: Colors.grey.shade300, borderWidth: 1, ), closeButtonConfig: const CloseButtonConfiguration( show: true, color: Colors.grey, ), constraints: const BoxConstraints(maxWidth: 300), content: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisSize: MainAxisSize.min, children: [ const Text( 'Confirm Action', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), ), const SizedBox(height: 12), const Text('Are you sure you want to continue?'), const SizedBox(height: 16), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ ElevatedButton( onPressed: () => _controller.hideTooltip(), child: const Text('Cancel'), ), ElevatedButton( onPressed: () { // Handle action _controller.hideTooltip(); }, child: const Text('Confirm'), ), ], ), ], ), ), child: ElevatedButton( onPressed: () => _controller.showTooltip(), child: const Text('Delete'), ), ) ``` -------------------------------- ### Super Tooltip with GestureDetector Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Shows how to integrate SuperTooltip with GestureDetector for explicit tap control. This allows manual triggering of the tooltip's display. ```dart GestureDetector( onTap: () => _controller.showTooltip(), child: SuperTooltip( controller: _controller, content: const Text( "Lorem ipsum dolor sit amet, consetetur sadipscing elitr", softWrap: true, style: TextStyle(color: Colors.white), ), child: Container( width: 40.0, height: 40.0, decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.blue, ), child: const Icon(Icons.add, color: Colors.white), ), ), ) ``` -------------------------------- ### TooltipStyle Configuration Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Customize the visual appearance of the tooltip using the TooltipStyle object. This includes background color, border, shadow, and padding. ```dart SuperTooltip( style: TooltipStyle( backgroundColor: Colors.deepPurple, borderColor: Colors.purpleAccent, borderWidth: 2.0, borderRadius: 15.0, hasShadow: true, shadowColor: Colors.black26, shadowBlurRadius: 20.0, bubbleDimensions: EdgeInsets.all(12), ), // ... ) ``` -------------------------------- ### Configure User Interaction Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Control how users interact with the tooltip. Options include showing on hover, hiding on exit, toggling on tap, and hiding on barrier tap. ```dart SuperTooltip( interactionConfig: InteractionConfiguration( showOnHover: true, // Show on mouse hover (Web/Desktop) hideOnHoverExit: true, // Hide when mouse leaves toggleOnTap: true, // Toggle on/off with taps hideOnTap: false, // Hide when tooltip is tapped hideOnBarrierTap: true, // Hide when barrier is tapped hideOnScroll: false, // Hide on scroll clickThrough: false, // Allow clicks through tooltip ), // ... ) ``` -------------------------------- ### Configure Animation Timing Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Control animation behavior for showing and hiding the tooltip. Adjust fade durations, wait times, and display durations. ```dart SuperTooltip( animationConfig: AnimationConfiguration( fadeInDuration: Duration(milliseconds: 300), fadeOutDuration: Duration(milliseconds: 200), waitDuration: Duration(milliseconds: 500), // Delay before showing showDuration: Duration(seconds: 3), // Auto-dismiss after duration exitDuration: Duration(milliseconds: 100), // Hover exit delay ), // ... ) ``` -------------------------------- ### Configure Backdrop Effects Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Control the backdrop behind the tooltip. You can set its color, enable a blur effect, and adjust blur parameters. ```dart SuperTooltip( barrierConfig: BarrierConfiguration( show: true, color: Colors.black54, showBlur: true, // Enable blur effect sigmaX: 10.0, sigmaY: 10.0, ), // ... ) ``` -------------------------------- ### Enable Auto Direction for Tooltip Positioning Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Demonstrates the use of TooltipDirection.auto in PositionConfiguration to allow the tooltip to automatically determine its best position. This ensures the tooltip is always visible and well-placed relative to its child. ```dart positionConfig: PositionConfiguration( preferredDirection: TooltipDirection.auto, ) ``` -------------------------------- ### Callbacks for Tooltip Events Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md React to tooltip state changes using `onShow` and `onHide` callbacks. These are useful for triggering animations or tracking analytics. ```dart SuperTooltip( controller: _controller, onShow: () { print('Tooltip shown!'); // Start animation, track analytics, etc. }, onHide: () { print('Tooltip hidden!'); // Continue tutorial, clean up, etc. }, content: const Text("Hello!"), child: const Icon(Icons.info), ) ``` -------------------------------- ### ArrowConfiguration for Tooltip Arrow Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Customize the shape and size of the tooltip's arrow using ArrowConfiguration. Parameters control the arrow's length, base width, and tip radius. ```dart SuperTooltip( arrowConfig: ArrowConfiguration( length: 20.0, baseWidth: 25.0, tipRadius: 5.0, tipDistance: 3.0, ), // ... ) ``` -------------------------------- ### Dispose Tooltip Controller Lifecycle Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Highlights the best practice of disposing of the SuperTooltip controller when it's no longer needed to prevent memory leaks. This should be done within the dispose method of the widget. ```dart @override void dispose() { _controller.dispose(); super.dispose(); } ``` -------------------------------- ### PositionConfiguration for Tooltip Placement Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Control the tooltip's position relative to its child widget using PositionConfiguration. Options include auto-direction, margins, and fixed positioning. ```dart SuperTooltip( positionConfig: PositionConfiguration( preferredDirection: TooltipDirection.auto, // or up, down, left, right minimumOutsideMargin: 20.0, top: 10.0, // Optional fixed positioning left: 10.0, snapsFarAwayVertically: false, ), // ... ) ``` -------------------------------- ### Auto-Dismiss Tooltip Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Create a tooltip that automatically dismisses after a specified duration. Use the `showDuration` property within `AnimationConfiguration`. ```dart SuperTooltip( controller: _controller, animationConfig: const AnimationConfiguration( showDuration: Duration(seconds: 3), // Auto-dismiss after 3 seconds ), content: const Text( "I'll close automatically!", style: TextStyle(color: Colors.white), ), child: const Icon(Icons.notifications), ) ``` -------------------------------- ### Enable Mouse Hover Support for Tooltip Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Configure SuperTooltip to show on mouse hover and hide when the mouse exits the child widget. This is useful for web and desktop platforms. Ensure interactionConfig is set to showOnHover and hideOnHoverExit. ```dart SuperTooltip( controller: _controller, interactionConfig: const InteractionConfiguration( showOnHover: true, // Show on mouse enter hideOnHoverExit: true, // Hide on mouse exit ), animationConfig: const AnimationConfiguration( waitDuration: Duration(milliseconds: 500), // Delay before showing exitDuration: Duration(milliseconds: 100), // Delay before hiding ), mouseCursor: SystemMouseCursors.help, // Custom cursor on hover content: const Text("Hover tooltip"), child: const Icon(Icons.help), ) ``` -------------------------------- ### Add Dependency to pubspec.yaml Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Ensure the super_tooltip package is listed under dependencies in your pubspec.yaml file. This is typically done automatically by 'flutter pub add'. ```yaml dependencies: super_tooltip: latest ``` -------------------------------- ### Handle Back Button Press (Android) Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Dismiss the tooltip when the Android back button is pressed instead of exiting the screen. This involves using `PopScope` and checking the tooltip's visibility. ```dart class MyWidget extends StatefulWidget { @override State createState() => _MyWidgetState(); } class _MyWidgetState extends State { final _controller = SuperTooltipController(); Future _willPopCallback() async { // If the tooltip is open, close it instead of popping the page if (_controller.isVisible) { await _controller.hideTooltip(); return false; } return true; } @override Widget build(BuildContext context) { return PopScope( onPopInvokedWithResult: (didPop, result) => _willPopCallback(), child: GestureDetector( onTap: () => _controller.showTooltip(), child: SuperTooltip( controller: _controller, content: const Text("Tooltip content"), child: const Icon(Icons.info), ), ), ); } } ``` -------------------------------- ### Configure Close Button Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Add a close button to your tooltip. You can control its visibility, type (inside/outside), color, and size. ```dart SuperTooltip( closeButtonConfig: CloseButtonConfiguration( show: true, type: CloseButtonType.inside, // or CloseButtonType.outside color: Colors.white, size: 24.0, ), // ... ) ``` -------------------------------- ### Toggle Tooltip on Tap Source: https://github.com/bensonarafat/super_tooltip/blob/master/README.md Configure a tooltip to toggle its visibility when the child widget is tapped. Set `toggleOnTap` to true in `InteractionConfiguration`. ```dart SuperTooltip( controller: _controller, interactionConfig: const InteractionConfiguration( toggleOnTap: true, hideOnBarrierTap: false, // Only toggle via child taps ), content: const Text( "Tap the icon again to close", style: TextStyle(color: Colors.white), ), child: const Icon(Icons.info), ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.