@@ -842,21 +842,28 @@ class _InkResponseState extends State<_InkResponseStateWidget>
842842 widget.radius != oldWidget.radius ||
843843 widget.borderRadius != oldWidget.borderRadius ||
844844 widget.highlightShape != oldWidget.highlightShape) {
845- final InkHighlight ? hoverHighLight = _highlights[_HighlightType .hover];
846- if (hoverHighLight != null ) {
847- hoverHighLight .dispose ();
845+ final InkHighlight ? hoverHighlight = _highlights[_HighlightType .hover];
846+ if (hoverHighlight != null ) {
847+ hoverHighlight .dispose ();
848848 updateHighlight (_HighlightType .hover, value: _hovering, callOnHover: false );
849849 }
850- final InkHighlight ? focusHighLight = _highlights[_HighlightType .focus];
851- if (focusHighLight != null ) {
852- focusHighLight .dispose ();
850+ final InkHighlight ? focusHighlight = _highlights[_HighlightType .focus];
851+ if (focusHighlight != null ) {
852+ focusHighlight .dispose ();
853853 // Do not call updateFocusHighlights() here because it is called below
854854 }
855855 }
856856 if (enabled != isWidgetEnabled (oldWidget)) {
857857 statesController.update (MaterialState .disabled, ! enabled);
858858 if (! enabled) {
859859 statesController.update (MaterialState .pressed, false );
860+ // Remove the existing hover highlight immediately when enabled is false.
861+ // Do not rely on updateHighlight or InkHighlight.deactivate to not break
862+ // the expected lifecycle which is updating _hovering when the mouse exit.
863+ // Manually updating _hovering here or calling InkHighlight.deactivate
864+ // will lead to onHover not being called or call when it is not allowed.
865+ final InkHighlight ? hoverHighlight = _highlights[_HighlightType .hover];
866+ hoverHighlight? .dispose ();
860867 }
861868 // Don't call widget.onHover because many widgets, including the button
862869 // widgets, apply setState to an ancestor context from onHover.
@@ -937,7 +944,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
937944 _highlights[type] = InkHighlight (
938945 controller: Material .of (context),
939946 referenceBox: referenceBox,
940- color: resolvedOverlayColor,
947+ color: enabled ? resolvedOverlayColor : resolvedOverlayColor. withAlpha ( 0 ) ,
941948 shape: widget.highlightShape,
942949 radius: widget.radius,
943950 borderRadius: widget.borderRadius,
0 commit comments