File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
flutter-idea/src/io/flutter/actions Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,15 @@ abstract public class FlutterAppAction extends DumbAwareAction {
2323 @ NotNull private final Computable <Boolean > myIsApplicable ;
2424 @ NotNull private final String myActionId ;
2525
26+ // The current action event.
27+ private AnActionEvent myEvent ;
2628 private final FlutterApp .FlutterAppListener myListener = new FlutterApp .FlutterAppListener () {
2729 @ Override
2830 public void stateChanged (FlutterApp .State newState ) {
29- getTemplatePresentation ().setEnabled (myApp .isStarted () && myIsApplicable .compute ());
31+ // Access the action presentation through the most recently cached action event.
32+ if (myEvent != null ) {
33+ myEvent .getPresentation ().setEnabled (myApp .isStarted () && Boolean .TRUE .equals (myIsApplicable .compute ()));
34+ }
3035 }
3136 };
3237 private boolean myIsListening = false ;
@@ -71,10 +76,13 @@ private void updateActionRegistration(boolean isConnected) {
7176 public void update (@ NotNull final AnActionEvent e ) {
7277 updateActionRegistration (myApp .isConnected ());
7378
74- final boolean isConnected = myIsApplicable .compute ();
79+ final boolean isConnected = Boolean . TRUE . equals ( myIsApplicable .compute () );
7580 final boolean supportsReload = myApp .getMode ().supportsReload ();
7681 e .getPresentation ().setEnabled (myApp .isStarted () && isConnected && supportsReload );
7782
83+ // Cache the current event so that listeners can access its presentation.
84+ myEvent = e ;
85+
7886 if (isConnected ) {
7987 if (!myIsListening ) {
8088 getApp ().addStateListener (myListener );
You can’t perform that action at this time.
0 commit comments