@@ -842,21 +842,28 @@ class _InkResponseState extends State<_InkResponseStateWidget>
842
842
widget.radius != oldWidget.radius ||
843
843
widget.borderRadius != oldWidget.borderRadius ||
844
844
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 ();
848
848
updateHighlight (_HighlightType .hover, value: _hovering, callOnHover: false );
849
849
}
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 ();
853
853
// Do not call updateFocusHighlights() here because it is called below
854
854
}
855
855
}
856
856
if (enabled != isWidgetEnabled (oldWidget)) {
857
857
statesController.update (MaterialState .disabled, ! enabled);
858
858
if (! enabled) {
859
859
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 ();
860
867
}
861
868
// Don't call widget.onHover because many widgets, including the button
862
869
// widgets, apply setState to an ancestor context from onHover.
@@ -937,7 +944,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
937
944
_highlights[type] = InkHighlight (
938
945
controller: Material .of (context),
939
946
referenceBox: referenceBox,
940
- color: resolvedOverlayColor,
947
+ color: enabled ? resolvedOverlayColor : resolvedOverlayColor. withAlpha ( 0 ) ,
941
948
shape: widget.highlightShape,
942
949
radius: widget.radius,
943
950
borderRadius: widget.borderRadius,
0 commit comments