chat_context_menu 3.2.0
chat_context_menu: ^3.2.0 copied to clipboard
A Flutter package that provides chat context menu with customizable appearance and animations, perfect for chat applications.
Chat Context Menu ChangeLog #
3.2.0 #
ChatContextMenuAnimationStyle— Built-in menu animations, defaultscaleFade(existing 150ms overlay fade+scale). NewcupertinoSheetmatches Flutter's Cupertino context-menu sheet (335ms,easeOutBack/easeInBack, linear fade, scale from the arrow).transitionsBuilderstill overrides both. OptionaltransitionDurations/transitionDurationoverride the style default when non-null.- Example — Third tab (
Animation) compares the two styles on bubbles, a horizontal menu, andChatSelectableText. - Tests — Widget coverage for both styles, horizontal
cupertinoSheet, customtransitionsBuildernot stacking the sheet transition, and duration overrides.
3.1.0 #
- Nested Navigator / desktop multi-pane support — Fixes broken menu positioning and clipping when the anchor lives inside a nested
Navigator(e.g. desktop "sliding window" layouts where each pane hosts its own Navigator wrapped inClipRect/Transform.translate/clippedMaterial).useRootNavigatoronChatContextMenuWrapper(defaultfalse) — Pushes the menu route onto the rootNavigatorso the menu and barrier cover the whole window instead of being clipped to a single pane.useRootOverlayonChatSelectableText(defaultfalse) — Inserts selection handles, menu and barrier into the rootOverlayfor the same reason.- Overlay-space coordinates everywhere — The anchor rect and pointer position are now measured in the target Navigator's Overlay coordinate space (
localToGlobal(..., ancestor: overlayBox)) instead of raw window coordinates, so menus position correctly regardless of which Navigator the route is pushed onto. Layouts andbuildTransitionsuse the actual overlay size instead ofMediaQuery.of(context).size. - Clip-aware barrier cutout —
clipAnchorRectForHole(renamed fromclipAnchorGlobalRectForHole) now walks the render tree from the anchor to the overlay and intersects with every clipping ancestor (RenderAbstractViewport,ClipRect/ClipRRect/ClipOval/ClipPath,Material/PhysicalModelwith a non-noneclipBehavior), so withexcludeAnchorFromBarrier: truethe hole never extends past the visible pane bounds. - Backward compatible: with a single full-window Navigator (typical mobile apps) the overlay origin equals the window origin, so behavior is unchanged. Internal
HoleModalDismissScrim.holeRectGlobalwas renamed toholeRectLocaland theintersectHoleOverlayLocalhelper was removed (holes are already overlay-local).
- Tests — Added
test/nested_navigator_overlay_test.dartcovering a minimal sliding-pane reproduction (ClipRect > OverflowBox > Transform.translate > panes with nested Navigators): menu alignment with/withoutuseRootNavigator, hole-barrier hit-testing across panes, clip-chain clamping, andChatSelectableTextwithuseRootOverlay.
3.0.1 #
- Fix
ChatSelectableTextmenu overflow — Menu positioning now measures the full menu shell (menuPadding+ content), matchingChatContextMenuWrapper/ChatContextMenuVerticalLayout. Previously onlymenuBuildercontent was measured, so horizontal edge clamping underestimated the rendered width and the menu could extend past the screen edge (e.g. right-aligned chat bubbles). - Tests — Added
test/chat_selectable_text_test.dartto assert the menu stays withinhorizontalMarginat the screen edge.
3.0.0 #
- BREAKING:
hideMenuonwidgetBuilder—ContextMenuWidgetBuildernow receives a thirdhideMenucallback alongsideshowMenu. Callers must update theirwidgetBuildersignature; use_if the callback is not needed.hideMenucloses the menu only when it is already open (no-op otherwise), matching the behavior ofmenuBuilder'shideMenu. - Tests — Added a widget test verifying
hideMenufromwidgetBuilderwhen the menu is closed and when it is open. - Docs — Updated README / README_ZH examples and customization notes for the new
widgetBuilderAPI.
Migration #
// Before (2.x)
widgetBuilder: (context, showMenu) { ... }
// After (3.0.0)
widgetBuilder: (context, showMenu, hideMenu) { ... }
2.3.0 #
- Hole barrier and dismiss scrim — When
excludeAnchorFromBarrieris true andbarrierColoris non-transparent, the modal uses a punched overlay plus an in-route full-screen dismiss layer (HoleModalDismissScrim) so taps on the dimmed area reliably close the menu (fixes hits not reaching the underlying barrier stack entry). Barrier painting remains inHoleModalBarrier(hit-test transparent); dismiss uses the same hole geometry as the visual cutout. barrierAnchorBorderRadiusonChatContextMenuWrapper— OptionalBorderRadiusfor the anchor cutout so the hole can match rounded chat bubbles (RRectpainting and hit testing viaanchoredHoleShape/intersectHoleOverlayLocal).- Anchor rect clipping — Before pushing the route, the anchor global
Rectis clipped withclipAnchorGlobalRectForHole: intersect with the innermostRenderAbstractViewport(e.g.ListViewviewport) and withMediaQuerysize, so very tall list items no longer “punch” the overlay through the input bar or other UI below the scroll viewport. - Route
offstagegating —_useHoleBarrierno longer requires!offstage; the dismiss scrim stays in the page subtree whileOffstagestill suppresses interaction until the route is onstage. - Example:
barrierAnchorBorderRadiusaligned with bubble decoration (BorderRadius.circular(10)in the chat demo).
2.1.0 #
- Add
ChatSelectableTextwidget — a fully custom selectable text widget built from the ground up- Uses
RichTextfor rendering,TextPainterfor selection geometry,OverlayEntryfor handles/menu,CompositedTransformFollowerfor positioning - Text selection with draggable handles (base & extent) for adjustable selection range
- Customizable selection highlight color (
selectionColor) and handle color (handleColor) - Context menu with arrow indicator, smart positioning with pointer-position fallback for long text
selectAllOnActivateproperty — whentrue(default), selects all text on activation; whenfalse, selects the tapped wordselectAllcallback provided inmenuBuilderfor programmatic select-all from the menu- Auto-scroll when dragging handles near viewport edges (
autoScrollEdgeExtent,autoScrollSpeed) - Haptic feedback on selection activation (
enableHapticFeedback) - Handle visibility — handles are automatically hidden when scrolled outside the viewport
- Menu-only animation (text and selection appear immediately, only the menu panel animates)
- Customizable menu appearance:
menuBackgroundColor,menuBorderRadius,menuPadding,menuShadows - Customizable arrow:
arrowHeight,arrowWidth,spacing,horizontalMargin onSelectionChangedcallback provides the currently selected textonMenuClosedcallback triggered when the menu is dismissed- Custom
transitionsBuilderfor menu animation
- Uses
1.7.4 #
- transitionsBuilder add centerOffset parameter to control the animation origin point
1.7.3 #
- transitionsBuilder add alignment parameter to control the animation origin point
1.7.2 #
- Use pointer (finger press) position as anchor when the widget is taller than available space for the context menu
1.7.1 #
- Fix
CurvedAnimationlistener leak in route transitions — replaced withanimation.drive(CurveTween(...)) - Fix
barrierDismissibleparameter being ignored (getter was hardcoded totrue) - Fix potential crash when widget is disposed while menu is closing (added
mountedcheck) - Add
disposetoChatContextMenuWrapperStateto clean up active route on widget removal - Rename
verticalMargintohorizontalMargininChatContextMenuHorizontalLayoutfor correct semantics - Fix
getInnerPathin both shape classes to properly return inset path - Remove unused
paddingparameter fromChatContextMenuHorizontalShape
1.7.0 #
** Add topPadding parameter
1.6.0 #
** Fix the issue of duplicate calculations in spacing
1.5.6 #
**The constraints parameter has been renamed to menuConstraints
** Added layoutConstraints parameter
** fix bug
1.5.1 #
** Export shape class
1.5.0 #
**Add constraints properties , to set maximum width and height for the context menu
** Add axis properties , to set the direction of the context menu (vertical or horizontal)
1.4.0 #
- add
onClosecallback , triggered when the context menu is closed - add
horizontalMarginproperties , Minimum horizontal margin from screen edges
1.3.0 #
- Add custom shadows attribute
- Add custom corner mark width and height
- Add properties for custom display spacing
- Add custom animation properties
1.2.0 #
- update
requestFocusparameter defaultfalse
1.1.0 #
- Added
requestFocusparameter toChatContextMenuWrapperto control focus behavior. Set it tofalseto prevent the menu from stealing focus from input fields.
1.0.0 #
- Initial release of
chat_context_menu. - Added
ChatContextMenuWrapperfor easy integration. - Supported customizable menu content via
menuBuilder. - Implemented automatic positioning with arrow indicator.
- Added customization options for colors and border radius.
