@@ -733,7 +733,6 @@ class _InkResponseState extends State<_InkResponseStateWidget>
733733 implements _ParentInkResponseState {
734734 Set <InteractiveInkFeature >? _splashes;
735735 InteractiveInkFeature ? _currentSplash;
736- bool _active = true ;
737736 bool _hovering = false ;
738737 final Map <_HighlightType , InkHighlight ?> _highlights = < _HighlightType , InkHighlight ? > {};
739738 late final Map <Type , Action <Intent >> _actionMap = < Type , Action <Intent >> {
@@ -780,16 +779,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
780779 @override
781780 void didUpdateWidget (_InkResponseStateWidget oldWidget) {
782781 super .didUpdateWidget (oldWidget);
783- final InkFeature ? validInkFeature = _getSingleInkFeature ();
784- if (validInkFeature != null && ! identical (validInkFeature.controller, Material .of (context)! )) {
785- _removeAllFeatures ();
786- if (_hovering && enabled)
787- updateHighlight (_HighlightType .hover, value: _hovering, callOnHover: false );
788- _updateFocusHighlights ();
789- return ;
790- }
791-
792- if (enabled != _isWidgetEnabled (oldWidget)) {
782+ if (_isWidgetEnabled (widget) != _isWidgetEnabled (oldWidget)) {
793783 if (enabled) {
794784 // Don't call wigdet.onHover because many wigets, including the button
795785 // widgets, apply setState to an ancestor context from onHover.
@@ -799,47 +789,12 @@ class _InkResponseState extends State<_InkResponseStateWidget>
799789 }
800790 }
801791
802- InkFeature ? _getSingleInkFeature () {
803- final List <InkFeature ?> inkFeatures = < InkFeature ? > [...? _splashes, ..._highlights.values];
804- assert (() {
805- MaterialInkController ? lastController;
806- for (final InkFeature ? inkFeature in inkFeatures) {
807- if (inkFeature == null )
808- continue ;
809- final MaterialInkController controller = inkFeature.controller;
810- if (lastController != null && ! identical (controller, lastController))
811- return false ;
812- lastController = controller;
813- }
814- return true ;
815- }());
816- final InkFeature ? validInkFeature = inkFeatures.firstWhere ((InkFeature ? inkFeature) => inkFeature != null , orElse: () => null );
817- return validInkFeature;
818- }
819-
820792 @override
821793 void dispose () {
822- _removeAllFeatures ();
823794 FocusManager .instance.removeHighlightModeListener (_handleFocusHighlightModeChange);
824795 super .dispose ();
825796 }
826797
827- void _removeAllFeatures () {
828- if (_splashes != null ) {
829- final Set <InteractiveInkFeature > splashes = _splashes! ;
830- _splashes = null ;
831- for (final InteractiveInkFeature splash in splashes)
832- splash.dispose ();
833- _currentSplash = null ;
834- }
835- assert (_currentSplash == null );
836- for (final _HighlightType highlight in _highlights.keys) {
837- _highlights[highlight]? .dispose ();
838- _highlights[highlight] = null ;
839- }
840- widget.parentState? .markChildInkResponsePressed (this , false );
841- }
842-
843798 @override
844799 bool get wantKeepAlive => highlightsExist || (_splashes != null && _splashes! .isNotEmpty);
845800
@@ -875,8 +830,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
875830 void handleInkRemoval () {
876831 assert (_highlights[type] != null );
877832 _highlights[type] = null ;
878- if (_active)
879- updateKeepAlive ();
833+ updateKeepAlive ();
880834 }
881835
882836 if (type == _HighlightType .pressed) {
@@ -1059,26 +1013,24 @@ class _InkResponseState extends State<_InkResponseStateWidget>
10591013 }
10601014 }
10611015
1062- void _setAllFeaturesVisible (bool visible) {
1063- for (final InkFeature ? splash in < InkFeature ? > [...? _splashes, ..._highlights.values])
1064- splash? .visible = visible;
1065- }
1066-
10671016 @override
10681017 void deactivate () {
1069- _active = ! _active;
1070- _setAllFeaturesVisible (false );
1018+ if (_splashes != null ) {
1019+ final Set <InteractiveInkFeature > splashes = _splashes! ;
1020+ _splashes = null ;
1021+ for (final InteractiveInkFeature splash in splashes)
1022+ splash.dispose ();
1023+ _currentSplash = null ;
1024+ }
1025+ assert (_currentSplash == null );
1026+ for (final _HighlightType highlight in _highlights.keys) {
1027+ _highlights[highlight]? .dispose ();
1028+ _highlights[highlight] = null ;
1029+ }
1030+ widget.parentState? .markChildInkResponsePressed (this , false );
10711031 super .deactivate ();
10721032 }
10731033
1074- @override
1075- void reactivate () {
1076- _active = ! _active;
1077- _setAllFeaturesVisible (true );
1078- updateKeepAlive ();
1079- super .reactivate ();
1080- }
1081-
10821034 bool _isWidgetEnabled (_InkResponseStateWidget widget) {
10831035 return widget.onTap != null || widget.onDoubleTap != null || widget.onLongPress != null ;
10841036 }
@@ -1249,10 +1201,6 @@ class _InkResponseState extends State<_InkResponseStateWidget>
12491201/// during animation. You should avoid using InkWells within [Material] widgets
12501202/// that are changing size.
12511203///
1252- /// Animations triggered by an [InkWell] will survive their widget moving due
1253- /// to [GlobalKey] reparenting, as long as the nearest [Material] ancestor is
1254- /// the same before and after the move.
1255- ///
12561204/// See also:
12571205///
12581206/// * [GestureDetector] , for listening for gestures without ink splashes.
0 commit comments