Skip to content

Conversation

@akhil-ge0rge
Copy link
Contributor

@akhil-ge0rge akhil-ge0rge commented Dec 16, 2025

Description

Add support for Tooltip widget in Stac.

Related Issues

Closes #396

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Code refactor
  • Build configuration change
  • Documentation
  • Chore

Summary by CodeRabbit

  • New Features

    • Added a configurable Tooltip widget supporting rich messages, trigger modes (tap/long-press/manual), timing, styling, decoration, and child content via JSON.
  • Examples

    • New gallery example demonstrating basic, styled, delayed, icon-button, and tap-triggered tooltips.
    • Gallery home updated with a "Stac Tooltip" entry linking to the example.
  • Documentation

    • New docs page detailing Tooltip properties and JSON usage examples.

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant
Copy link

CLAassistant commented Dec 16, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

Walkthrough

Adds first-class Tooltip support: new StacTooltip model + generated JSON (de)serialization, WidgetType.tooltip, StacTooltipTriggerMode and parser, Tooltip widget parser and service registration, example JSON asset and documentation. (50 words)

Changes

Cohort / File(s) Summary
Core Tooltip Model
packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart, packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.g.dart
Add StacTooltip JsonSerializable model and generated (de)serialization, nested types and enum mappings.
Trigger Mode Enum & Parser
packages/stac_core/lib/foundation/ui_components/stac_tool_tip_trigger_mode.dart, packages/stac/lib/src/parsers/foundation/ui_components/stac_tool_tip_trigger_mode_parser.dart, packages/stac/lib/src/parsers/foundation/foundation.dart, packages/stac_core/lib/foundation/foundation.dart
Add StacTooltipTriggerMode enum and extension to convert to Flutter TooltipTriggerMode; re-export in foundation barrels.
Widget Parser
packages/stac/lib/src/parsers/widgets/stac_tool_tip/stac_tool_tip_parser.dart
Add StacToolTipParser mapping StacTooltip to Flutter Tooltip, validating message/richMessage, parsing nested fields (durations, styles, decoration, child).
Framework Registration & Spec
packages/stac/lib/src/framework/stac_service.dart, packages/stac_core/lib/foundation/specifications/widget_type.dart
Register the tooltip parser in service; add tooltip to WidgetType enum; update parser exports.
Examples & Docs
examples/stac_gallery/assets/json/home_screen.json, examples/stac_gallery/assets/json/tool_tip_example.json, docs/widgets/tool_tip.mdx, docs/docs.json
Add gallery entry and new tool_tip_example.json demonstrating variants; add documentation page and docs index entry; minor formatting in home_screen.json.

Sequence Diagram(s)

sequenceDiagram
  participant Gallery as Gallery JSON (asset)
  participant Service as StacService
  participant Parser as StacToolTipParser
  participant Flutter as Flutter Tooltip Widget

  Gallery->>Service: load JSON asset (type: "tooltip")
  Service->>Parser: select parser for WidgetType.tooltip
  Parser->>Parser: getModel(json) -> StacTooltip
  Parser->>Parser: parse nested fields (durations, styles, decoration, child)
  Parser->>Flutter: construct Tooltip widget with parsed config & child
  Service->>Flutter: return widget to UI for rendering
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect generated stac_tool_tip.g.dart for correct enum mapping and default values (e.g., enableTapToDismiss).
  • Verify StacToolTipParser enforces message vs richMessage and handles absent child safely.
  • Check stac_service.dart import/registration for ordering/circular dependency risk.
  • Review foundation barrel exports to ensure no export conflicts.

Possibly related PRs

Suggested reviewers

  • divyanshub024
  • Potatomonsta

Poem

🐰 I hopped through JSON with a curious wink,
I stitched messages, delays, and styles in a blink.
From model to parser I nudged the view,
Tiny hints now bloom where icons grew —
Hop, show, repeat — a tooltip's wink ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: introducing a stacTooltip widget with parser and example JSON, which directly matches the changeset.
Linked Issues check ✅ Passed All requirements from issue #396 are met: Tooltip widget support [#396], Flutter Material Design implementation [#396], parser for rendering [#396], documentation and examples provided [#396].
Out of Scope Changes check ✅ Passed All changes directly support the Tooltip widget feature: model definitions, parsers, exports, core types, example JSON, and documentation are all within scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0924f70 and c0843cc.

📒 Files selected for processing (3)
  • docs/docs.json (1 hunks)
  • docs/widgets/tool_tip.mdx (1 hunks)
  • packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/widgets/tool_tip.mdx
🔇 Additional comments (6)
docs/docs.json (1)

71-72: LGTM! Documentation navigation updated correctly.

The JSON syntax is valid and the new tooltip widget entry is properly added to the navigation structure.

packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (5)

1-5: LGTM! Imports and serialization setup are correct.

The imports are appropriate and the part directive correctly references the generated serialization code.


7-43: Excellent documentation with accurate examples.

The class documentation is comprehensive and the code examples (both Dart and JSON) are accurate and helpful. Past issues with type names and JSON structure have been properly addressed.


45-65: LGTM! Constructor design is sound.

The const constructor with comprehensive named parameters follows best practices. The enableTapToDismiss default of true correctly mirrors Flutter's Tooltip behavior.


67-153: Excellent field documentation and type usage.

All fields are comprehensively documented with clear explanations of their purpose and behavior. Past issues with type references have been properly addressed—all documentation now correctly references StacTooltipTriggerMode instead of Flutter's native type.


155-164: LGTM! Serialization methods follow standard patterns.

The type getter, fromJson factory, and toJson method correctly implement the json_serializable pattern and integrate with the StacWidget base class.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
packages/stac_core/lib/foundation/specifications/widget_type.dart (1)

240-241: Fix comment to match Flutter's naming convention.

The comment should use "Tooltip" (one word) instead of "Tool Tip" (two words) to align with Flutter's official widget name.

Apply this diff:

-  /// Tool Tip widget
+  /// Tooltip widget
   tooltip,
examples/stac_gallery/assets/json/toot_tip_example.json (1)

172-193: Consider adding consistent spacing before the last tooltip section.

The "Tap to see Tooltip" section at lines 172-193 lacks the sizedBox spacer (height: 32) that appears before other major sections in this example. This breaks the visual consistency established by earlier sections.

Apply this diff to add consistent spacing:

             }
         ]
     },
+    {
+        "type": "sizedBox",
+        "height": 32
+    },
     {
         "type": "text",
         "data": "Tap to see Tooltip",
packages/stac/lib/src/parsers/widgets/stac_tool_tip/stac_tool_tip_parser.dart (1)

16-36: Consider validating that either message or richMessage is provided.

The parser allows both model.message and model.richMessage to be null, which would result in a tooltip with no displayable content. Flutter's Tooltip widget accepts this but produces a tooltip that shows nothing when triggered, which may not be the intended behavior.

Consider adding validation in the parse method:

 @override
 Widget parse(BuildContext context, StacTooltip model) {
+  assert(
+    model.message != null || model.richMessage != null,
+    'Either message or richMessage must be provided for StacTooltip',
+  );
   return Tooltip(

Alternatively, handle this validation in the StacTooltip model constructor itself.

packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (1)

120-137: Clarify duration field documentation.

The comments state "Defined in milliseconds" for waitDuration, showDuration, and exitDuration, but these fields are typed as StacDuration?, not as raw numbers. This phrasing could be confusing since the actual JSON structure requires an object (e.g., { "milliseconds": 1000 }), not a bare integer.

Consider revising the documentation to be more explicit:

-  /// The length of time that a pointer must hover over a tooltip's widget
-  /// before the tooltip will be shown.
-  ///
-  /// Defined in milliseconds.
+  /// The length of time that a pointer must hover over a tooltip's widget
+  /// before the tooltip will be shown.
   final StacDuration? waitDuration;

Or update to:

  /// The length of time that a pointer must hover over a tooltip's widget
  /// before the tooltip will be shown.
  ///
  /// Expects a [StacDuration] object specifying the duration.
  final StacDuration? waitDuration;

Apply similar changes to showDuration (lines 126-131) and exitDuration (lines 133-137).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 460a4c1 and 9ccd1f8.

📒 Files selected for processing (12)
  • examples/stac_gallery/assets/json/home_screen.json (1 hunks)
  • examples/stac_gallery/assets/json/toot_tip_example.json (1 hunks)
  • packages/stac/lib/src/framework/stac_service.dart (2 hunks)
  • packages/stac/lib/src/parsers/foundation/foundation.dart (1 hunks)
  • packages/stac/lib/src/parsers/foundation/ui_components/stac_tool_tip_trigger_mode_parser.dart (1 hunks)
  • packages/stac/lib/src/parsers/widgets/stac_tool_tip/stac_tool_tip_parser.dart (1 hunks)
  • packages/stac_core/lib/foundation/foundation.dart (1 hunks)
  • packages/stac_core/lib/foundation/specifications/widget_type.dart (1 hunks)
  • packages/stac_core/lib/foundation/ui_components/stac_tool_tip_trigger_mode.dart (1 hunks)
  • packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (1 hunks)
  • packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.g.dart (1 hunks)
  • packages/stac_core/lib/widgets/widgets.dart (1 hunks)
🔇 Additional comments (8)
packages/stac/lib/src/parsers/foundation/foundation.dart (1)

113-113: LGTM!

The export is correctly placed and follows the alphabetical ordering convention within the UI components section.

packages/stac/lib/src/parsers/foundation/ui_components/stac_tool_tip_trigger_mode_parser.dart (1)

1-17: LGTM!

The parser extension correctly maps all StacTooltipTriggerMode enum values to their corresponding Flutter TooltipTriggerMode values using an exhaustive switch.

packages/stac/lib/src/framework/stac_service.dart (2)

19-19: LGTM!

The import for StacToolTipParser is correctly added alongside other widget parser imports.


103-103: LGTM!

The StacToolTipParser is correctly registered in the global parsers list.

packages/stac_core/lib/widgets/widgets.dart (1)

82-82: LGTM!

The export is correctly placed in alphabetical order within the widgets barrel file.

packages/stac_core/lib/foundation/foundation.dart (1)

109-109: LGTM!

The export is correctly placed in alphabetical order within the UI components section of the foundation library.

packages/stac_core/lib/foundation/ui_components/stac_tool_tip_trigger_mode.dart (1)

1-15: LGTM!

The enum correctly mirrors Flutter's TooltipTriggerMode with clear documentation for each variant.

packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.g.dart (1)

1-91: Generated code looks correct.

The JSON serialization code is properly generated with appropriate null handling, enum mappings, and default values.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/widgets/tool_tip.mdx (2)

85-85: Add blank line before heading for consistency.

The markdown formatting should include a blank line before the heading for better readability and consistency with other sections.

Apply this diff:

 }

Tooltip with Delay & Duration


---

`40-157`: **Consider adding examples for additional properties (optional).**

The current examples are excellent and cover common use cases. For completeness, consider adding examples demonstrating:
- `triggerMode` (e.g., showing the difference between `longPress` and `tap`)
- `enableTapToDismiss` set to `false`
- `textAlign` with different alignments
- `constraints` for controlling tooltip dimensions

This would help users understand the full range of customization options.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: CodeRabbit UI

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between a1720b7af53c17571595998567afb888ac63806f and 0099a40b854060b19678885458544743f13bc96c.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `docs/widgets/tool_tip.mdx` (1 hunks)
* `packages/stac_core/lib/foundation/specifications/widget_type.dart` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* packages/stac_core/lib/foundation/specifications/widget_type.dart

</details>

<details>
<summary>🔇 Additional comments (2)</summary><blockquote>

<details>
<summary>docs/widgets/tool_tip.mdx (2)</summary><blockquote>

`1-14`: **LGTM!**

The introduction is clear, well-structured, and appropriately references the official Flutter documentation.

---

`15-37`: **Verify property definitions against Flutter's Tooltip API.**

The properties table documents the Stac Tooltip widget. Confirm that all properties, their types, default values, and behaviors align with Flutter's Tooltip widget API, especially:
- Line 25: `preferBelow` default of `true`
- Line 33: `enableTapToDismiss` default of `true`
- Line 34: `triggerMode` values (`longPress` or `tap`)

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0099a40 and 67e3988.

📒 Files selected for processing (3)
  • examples/stac_gallery/assets/json/home_screen.json (1 hunks)
  • packages/stac/lib/src/parsers/widgets/stac_tool_tip/stac_tool_tip_parser.dart (1 hunks)
  • packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/stac/lib/src/parsers/widgets/stac_tool_tip/stac_tool_tip_parser.dart
  • examples/stac_gallery/assets/json/home_screen.json
🔇 Additional comments (3)
packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (3)

1-5: LGTM: Clean imports and standard code generation setup.

The imports are appropriate for JSON serialization and the Stac widget foundation. The part directive follows the standard pattern for json_serializable.


43-152: LGTM: Well-structured widget model with comprehensive documentation.

The class declaration, constructor, and field definitions follow Dart best practices:

  • Appropriate use of nullable types for optional configurations
  • Sensible default for enableTapToDismiss (true)
  • Clear documentation for each field, including units and behavioral notes
  • Proper alignment with Flutter's Tooltip API

154-163: LGTM: Standard serialization implementation.

The type getter and JSON serialization methods follow the established Stac widget patterns correctly, delegating to the generated code as expected.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67e3988 and ae7a2fc.

📒 Files selected for processing (1)
  • packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (1 hunks)
🔇 Additional comments (6)
packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (6)

1-5: LGTM!

The imports and part directive are correctly configured for JSON serialization and widget definition.


7-43: LGTM!

The documentation is comprehensive and includes helpful Dart and JSON examples. The previously reported issues with type names and JSON structure have been addressed.


43-65: LGTM!

The class declaration and constructor are well-structured. The explicitToJson: true annotation is appropriate for nested serialization, and the enableTapToDismiss default value of true correctly matches Flutter's Tooltip default.


154-155: LGTM!

The type getter correctly returns the tooltip widget type identifier.


157-163: LGTM!

The serialization methods correctly delegate to the generated JSON helpers.


67-152: The height property omission is intentional and correct.

Flutter deprecated the height property in favor of constraints (BoxConstraints) as of v3.30.0. The StacTooltip already provides the constraints property (StacBoxConstraints), which is the modern approach for controlling tooltip sizing.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae7a2fc and 0924f70.

📒 Files selected for processing (1)
  • packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (1 hunks)
🔇 Additional comments (5)
packages/stac_core/lib/widgets/tool_tip/stac_tool_tip.dart (5)

1-5: LGTM!

The imports and part directive are correctly structured for JSON serialization with the Stac framework.


7-42: LGTM!

The documentation is comprehensive and provides clear examples in both Dart and JSON formats. All previously flagged issues have been addressed.


43-65: LGTM!

The class declaration and constructor are well-structured. The enableTapToDismiss = true default aligns with Flutter's Tooltip API.


133-153: LGTM!

The remaining field declarations are well-documented and use appropriate types. The field coverage comprehensively mirrors Flutter's Tooltip API.


155-165: LGTM!

The serialization methods follow the standard json_serializable pattern, and the type getter correctly returns WidgetType.tooltip.name.

@akhil-ge0rge
Copy link
Contributor Author

Hi @divyanshub024 , @Potatomonsta 👋,
Please take a look. Thanks!

Copy link
Member

@divyanshub024 divyanshub024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution 🙌🚀

@akhil-ge0rge
Copy link
Contributor Author

@divyanshub024 Should I also add StacTooltipThemeData in this PR?

@divyanshub024
Copy link
Member

@divyanshub024 Should I also add StacTooltipThemeData in this PR?

Thats a good idea. But can you please do it in another PR?

@akhil-ge0rge
Copy link
Contributor Author

Hi @divyanshub024

CI is failing with a Flutter engine download error.
Just checking if this is due to my changes or a CI/Flutter issue.

@divyanshub024 divyanshub024 merged commit dc7a5e5 into StacDev:dev Dec 19, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add support for Tooltip widget

3 participants