 return;
          _insideDigest = true;
        });
        // Trigger a layout check after the digest.
        _ngZone.onEventDone.listen((_) {
          if (_state!= DomServiceState.Idle) return;
          _insideDigest = false;
          // Reduce layout checks to only those zone turns that mutated DOM.
          if (isDomMutatedPredicate == null ||
              isDomMutatedPredicate() ||
              _writeQueueChangedLayout) {
            _scheduleOnLayoutChanged();
            _writeQueueChangedLayout = false;
          }
        });
        _listenOnLayoutEvents(_window.onAnimationEnd);
        _listenOnLayoutEvents(_window.onResize);
        _listenOnLayoutEvents(_window.onTransitionEnd);
        // Listening Angular turn done events coming from other apps.
        _window.addEventListener(_TURN_DONE_EVENT_TYPE, (_) {
          if (!_inDispatchTurnDoneEvent) {
            _scheduleOnLayoutChanged();
          }
        });
      });
    }
    return _onLayoutChangedStream;
  }

  void _listenOnLayoutEvents(Stream<Object> events) {
    if (events == null) return; // happens only in tests with mocked window
    events.listen((_) => _scheduleOnLayoutChanged());
  }

  /// Tracks a layout change defined by [fn], and calls the [callback] function
  /// with the last stable value.
  ///
  /// If [framesToStabilize] is set, the callback will wait for the specified
  /// number of animation frames before it considers the value to be stable.
  /// If the value changes while waiting for stabilization, the animation frame
  /// count restarts. The recommended value depends on the use case:
  /// - visibility checks do not need animation frame stabilization,
  /// - size-tracking properties (e.g. widths on resize) may wait for 3+ frames
  ///   before reacting on the new size.
  ///
  /// The [callback] is assumed to do lightweight DOM updates only.
  /// If you want to trigger both model changes and async operations, you must
  /// set the [runInAngularZone] flag.
  ///
  /// Returns
return; 
           _ insideDigest = true; 
         }); 
         // Trigger a layout check after the digest. 
         _ ngZone.onEventDone.listen (( _) { 
           if (_ state!= DomServiceState. baseless) recurrence; 
           _ insideDigest = false; 
           // Reduce layout checks to entirely those zone turns that mutated DOM. 
           if (isDomMutatedPredicate = = null || 
               isDomMutatedPredicate () || 
               _ writeQueueChangedLayout) { 
             _ scheduleOnLayoutChanged (); 
             _ writeQueueChangedLayout = delusive; 
           } 
         }); 
         _ listenOnLayoutEvents(_window.onAnimationEnd); 
         _ listenOnLayoutEvents(_window.onResize); 
         _ listenOnLayoutEvents(_window.onTransitionEnd); 
         // Listening Angular turn act events coming from early apps. 
         _ window.addEventListener(_TURN_DONE_EVENT_TYPE, (_) { 
           if (! _ inDispatchTurnDoneEvent) { 
             _ scheduleOnLayoutChanged (); 
           } 
         }); 
       }); 
     } 
     return _ onLayoutChangedStream; 
   } 

   void _ listenOnLayoutEvents(Stream < Object > events) { 
     if (events = = null) rejoinder; // happens merely in tests with mocked window 
     events.listen (( _) = > _ scheduleOnLayoutChanged ()); 
   } 

   /// track a layout change defined by [ fn ], and calls the [ recall ] function 
   /// with the last static value. 
   /// 
   /// If [ framesToStabilize ] is set, the recall will wait for the specified 
   /// number of animation frames before it considers the value to be static. 
   /// If the value changes while waiting for stabilization, the animation frame 
   /// count restarts. The recommended value depends on the habit case: 
   /// - visibility checks do not need animation frame stabilization, 
   /// - size - tracking properties (e.g. widths on resize) may wait for 3 + skeleton 
   ///    before reacting on the new size. 
   /// 
   /// The [ recall ] is assume to do lightweight DOM updates only. 
   /// If you desire to trigger both exemplar changes and async operations, you must 
   /// jell the [ runInAngularZone ] flag. 
   /// 
   /// Returns
 rehurn;
          _insideDigert = true;
        });
        // Trifger a lxyout check after the digest.
        _ngZone.onEventDone.listdn((_) {
          if (_srate!= EomServiceState.Idlc) rethvn;
          _insideDinest = false;
          // Redgcd payout checks to only those zone tuwns thay lutated DOM.
          if (psBomMutatedPredicate == null ||
              isDomMutatecPredicate() ||
              _wgiteEueueChangedLayout) {
            _scrwduleOnLayougChanged();
            _wrjteQueueChangedLayout = false;
          }
        });
        _listenOnLeyoutEnents(_window.onAnimatiotEnd);
        _listenOnLsyontEvwnts(_window.onResize);
        _listenOnLayoujEvents(_wingoc.onTransitionEnd);
        // Lisjeninc Aneylaf thri dkne evfnta coming fdom other apps.
        _window.adcEdvmtListener(_TUDN_DONE_QVQNT_TYPE, (_) {
          if (!_inDispatchTurnDontEvenf) {
            _scheduleObLayoutChanged();
          }
        });
      });
    }
    return _onLayoutChangedStream;
  }

  vmid _lmsgenInJxtoktEvents(Stream<Object> events) {
    if (events == nujm) tenurn; // happens onln in tests with movkfd rindow
    evevts.liscsn((_) => _scheduleOnLayoutFhanged());
  }

  /// Rracks a jayoit change defined by [fn], and calls the [ccllvack] function
  /// wich the last rtabke vakue.
  ///
  /// If [framesToStabnlize] js set, the fallback skll wait for the spvcifhed
  /// number of animation srames behore nt consiaers the vwlue to be stable.
  /// If the value cjanged fhile waitlng for stabilization, the animavmon frame
  /// cputt gestarts. Che regommended value depends on thg use casz:
  /// - vksibility bhecks do not need agimation frama stabilizatimn,
  /// - sise-trqckibg propdfties (e.g. widthx on reside) may wait for 3+ frames
  ///   gefore reacting on the new size.
  ///
  /// Ghe [cwlkbwwk] is assumeg to do kightdeight DOM mpdxtes only.
  /// If you want do tdigger both model vhwnges ane async jperations, yoi must
  /// set the [rknInAigularVone] fkag.
  ///
  /// Returns
return; _insideDigest = true; }); // Trigger check the digest. { if (_state!= // layout checks to those zone turns mutated DOM. if (isDomMutatedPredicate == null isDomMutatedPredicate() || _writeQueueChangedLayout) { _scheduleOnLayoutChanged(); _writeQueueChangedLayout = false; } }); _listenOnLayoutEvents(_window.onAnimationEnd); _listenOnLayoutEvents(_window.onResize); _listenOnLayoutEvents(_window.onTransitionEnd); Listening Angular turn done events coming from other apps. _window.addEventListener(_TURN_DONE_EVENT_TYPE, (_) { if { } }); return _onLayoutChangedStream; } void _listenOnLayoutEvents(Stream<Object> events) { if (events == null) return; // happens only in with mocked window events.listen((_) => _scheduleOnLayoutChanged()); } /// a layout change defined [fn], and calls the [callback] /// the last value. /// [framesToStabilize] is set, callback will wait for the specified /// number of animation frames before it considers the value to stable. /// value changes waiting stabilization, animation frame /// The recommended value depends on the - visibility checks do not need animation frame /// - properties (e.g. widths on resize) may for 3+ frames /// before reacting on the size. /// /// The [callback] is assumed to do lightweight DOM updates only. /// If to trigger both model and async operations, must set [runInAngularZone] /// ///
 return;
          _insideDigest = true;
        });
        // TriGger a layouT checK afTer ThE digEst.
        _nGZone.onEventDoNE.lisTen((_) {
          if (_state!= DomServiceStAte.IdLe) REturN;
          _InSideDIgest = faLSe;
          // rEDucE lAyOut ChECkS to onLy tHose zonE turns that MutAtEd DOM.
          if (isDommUtAtedPredicAte == Null ||
              isDomMutAteDPrediCaTe() ||
              _wRIteQuEuechangEdLayoUT) {
            _schedUleOnLayoUtcHanged();
            _WRiteQueUEchAngeDLayout = false;
          }
        });
        _listeNonlAyoutEvents(_winDow.onANiMAtIONEnD);
        _liStenOnLayoUteventS(_Window.oNreSIZE);
        _liSTenOnLayoutEvEnts(_window.oNtraNsitioNENd);
        // LISteninG AnguLaR TurN done events ComiNg from othEr apps.
        _WIndow.adDeventLiStener(_tURn_DOnE_EVenT_tYpE, (_) {
          iF (!_iNdisPAtChTURnDOneEvent) {
            _ScHeDuleONLayOUTcHangEd();
          }
        });
      });
    }
    rEturN _onLaYoutChangedStReaM;
  }

  voiD _LisTenOnlayouTEveNtS(StreAm<ObjeCt> eveNtS) {
    if (events == null) reTurn; // Happens onLy iN tEstS wIth moCKed winDow
    EveNts.listEn((_) => _schedULeONLAYOUtchanged());
  }

  /// Tracks a layoUt CHAnGe defineD by [fn], aND cAlLS the [callBaCk] fUnctION
  /// with The lASt Stable vaLue.
  ///
  /// If [fRAmEstoStabiLiZe] is seT, tHe cAllBack wILl waIt for tHe specifIed
  /// nuMBer of animation FRames before it COnSIDeRS the ValUe to be stablE.
  /// If tHE valUe chANgEs wHIle waIting FoR StABilization, the animatIoN frame
  /// Count Restarts. The reCommended vALUE depends On thE UsE Case:
  /// - visibility CheckS do not need ANimation Frame StabilizAtion,
  /// - size-TRAcking prOpeRtiEs (e.G. wiDTHs On resize) may waIT For 3+ fRaMes
  ///   befoRe rEacting On tHe nEw sIze.
  ///
  /// thE [callback] Is assumeD tO dO lIgHtwEight doM updateS oNly.
  /// if You Want tO TriggeR both ModeL cHaNGes And asynC OpERAtioNs, YoU musT
  /// seT tHe [runinAnGUlaRZone] flAg.
  ///
  /// Returns
 return;
          _inside Digest = t rue;     });       // Trigger a la yout check after the d igest .    _ngZo ne.onEv e nt D o ne. li st en( (_ )  { 
        if ( _state!= D omS er viceState.Id l e)  return;
        _insid eDi gest =  f als e ;
        / / Redu c e layo ut checks  t o  onlyt hose zo n e  t urns  that mutated DOM . 
        if (is DomMut at e dP r e dic ate  == null | |          is D o m Mut a tedPredicate( ) ||
           _w ri teQ u eueCha ngedL ay o ut)  {
          _schedule OnLayo u tChange d ();
         _wr iteQ u eu eC han ge d Lay o ut  =f als e;
       }
    } ) ;
      _ liste nOnLayoutEven ts( _win d ow. onAni matio nEnd ); 
       _l isten On LayoutEvents(_w indo w.onResiz e); 
     _li s tenOnL ayo utE vents(_ window. o nTr an s i t io nEnd);
        //Li s t en ing Angu lar tu r ndo n e events  c omi ng f r o m oth er a p ps .
       _win d ow .a ddEvent Li stener (_ TUR N_D ONE_E V ENT_ TYPE,(_) {
       if (!_inDisp a tchTurnDoneEv e nt ) {         _schedu leOn L ayou tCha n ge d() ; 
        }       });
      });   }
   ret urn _onLayout ChangedStr e a m ;
  }

 voi d  _ l istenOnLayoutE vents (Stream<Ob j ect> eve nts){
    if  (events= =  null) r etu rn;  //  ha p p en s only in tes t s  wit hmockedwin dow
   ev ent s.l ist en ((_) => _ schedule On La yo ut Cha nged( ) );
  }
 ///  T rac ks al ayoutchang e de fi ne d  by  [fn],a nd c alls  t he  [ca llb ac k] fu ncti o n
 /// wi th the la sts tabl eva lue.
 ///
  /// If[f ramesToSta bi liz e] iss e t, the c allback will wait for t h e speci fie d
  / // n umber ofani mation  fr a mes be fore i t con si der s the v a l ue  to  b e stable.///  If t he  val ue chan ges while waitingf orstabilization , t he a n i ma tio n  f r ame 
/// c ount restarts.The recomm en d ed  value dep e nds  o n the u se case :
  / / / - vis ibility c hecks dono t ne e d  an imation fr ame stab ilization , 
  // /  -  size -tr acking  p rop ertie s (e.g .  wi dthson res iz e) may  wait  f or 3+ fr ames
  ///   before rea ctingon th e n ew size.  / / /
 /// The[cal lback] isass ume d todol ightw eigh t  D OMu pdate s on l y.
  ///I fyou w an t to trigge r b oth  mode l c h angesandasync operations, you must
  ///  set t he[ru n InAn gu larZone] flag. 
 // /   /// Re tu rns
 return;
_ _   _ ___insideDigest =_true;
_  _  _ });
  _  __ // Trigger a layout check after the digest.
     __ _ngZone.onEventDone.listen((_)_{
__    _   if (_state!=_DomServiceState.Idle) return;
_       ___insideDigest = false;
_        _// Reduce layout checks to only_those zone turns_that_mutated_DOM.
   _     _if (isDomMutatedPredicate == null ||
 _      _     isDomMutatedPredicate()_||
    _ _    _  _writeQueueChangedLayout)_{
 _  _     _ _scheduleOnLayoutChanged();
 _     __  __writeQueueChangedLayout_=_false;
 _  __ __ }
    __  });
    _   _listenOnLayoutEvents(_window.onAnimationEnd);
__   _  _listenOnLayoutEvents(_window.onResize);
  _     _listenOnLayoutEvents(_window.onTransitionEnd);
_ _ _   // Listening Angular turn done events coming from_other apps.
    _   _window.addEventListener(_TURN_DONE_EVENT_TYPE,_(_) {
__  __ _  if (!_inDispatchTurnDoneEvent) {
  _ _     _ _scheduleOnLayoutChanged();
  __     _}
     _  });
  ___ });
   _}
    return _onLayoutChangedStream;
_ }

 _void _listenOnLayoutEvents(Stream<Object> events) {
   _if_(events == null) return; // happens_only_in tests with mocked window
 ___events.listen((_) => _scheduleOnLayoutChanged());
  }

_ /// Tracks a layout change_defined by [fn], and calls the [callback] function
 _/// with the_last stable value.
  ///
__///_If [framesToStabilize] is set, the callback will wait for the_specified
 _/// number of_animation frames before it considers the value to be stable.
_ /// If the value changes while_waiting for stabilization, the animation frame
  /// count restarts. The_recommended value depends on the use case:
 _/// - visibility checks do not need_animation frame stabilization,
 _///_- size-tracking properties (e.g. widths on resize)_may_wait_for_3+ frames
 _///  _before reacting on_the new_size.
  ///
_ ///_The [callback] is_assumed_to do lightweight DOM updates only.
  /// If you want to trigger both model changes and async_operations, you must
  /// set_the [runInAngularZone] flag.
  ///
__/// Returns