@@ -62,6 +62,8 @@ public FlutterWidgetPerf getCurrentStats() {
6262  private  boolean  trackRepaintWidgets  = trackRepaintWidgetsDefault ;
6363  private  boolean  debugIsActive ;
6464
65+   private  final  Set <PerfModel > listeners  = new  HashSet <>();
66+ 
6567  /** 
6668   * File editors visible to the user that might contain widgets. 
6769   */ 
@@ -197,6 +199,10 @@ private void debugActive(Project project, FlutterViewMessages.FlutterDebugEvent
197199      (TextEditor  textEditor ) -> new  EditorPerfDecorations (textEditor , app ),
198200      path  -> new  DocumentFileLocationMapper (path , app .getProject ())
199201    );
202+ 
203+     for  (PerfModel  listener  : listeners ) {
204+       currentStats .addPerfListener (listener );
205+     }
200206  }
201207
202208  public  void  stateChanged (FlutterApp .State  newState ) {
@@ -318,6 +324,21 @@ public void dispose() {
318324    if  (currentStats  != null ) {
319325      currentStats .dispose ();
320326      currentStats  = null ;
327+       listeners .clear ();
328+     }
329+   }
330+ 
331+   public  void  addPerfListener (PerfModel  listener ) {
332+     listeners .add (listener );
333+     if  (currentStats  != null ) {
334+       currentStats .addPerfListener (listener );
335+     }
336+   }
337+ 
338+   public  void  removePerfListener (PerfModel  listener ) {
339+     listeners .remove (listener );
340+     if  (currentStats  != null ) {
341+       currentStats .removePerfListener (listener );
321342    }
322343  }
323344}
0 commit comments