Why call not empty setState()? [duplicate]












0















This question already has an answer here:




  • Why does setState take a closure?

    2 answers




Why Flutter defines that we should call:



setState(() { _counter++});


instead of:



_counter++;
setState(() {});


As far as I can see in setState() code, it doesn't use anything that's passed as a parameter anyway.










share|improve this question













marked as duplicate by Rémi Rousselet flutter
Users with the  flutter badge can single-handedly close flutter questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 13 at 1:59


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















    0















    This question already has an answer here:




    • Why does setState take a closure?

      2 answers




    Why Flutter defines that we should call:



    setState(() { _counter++});


    instead of:



    _counter++;
    setState(() {});


    As far as I can see in setState() code, it doesn't use anything that's passed as a parameter anyway.










    share|improve this question













    marked as duplicate by Rémi Rousselet flutter
    Users with the  flutter badge can single-handedly close flutter questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 13 at 1:59


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















      0












      0








      0








      This question already has an answer here:




      • Why does setState take a closure?

        2 answers




      Why Flutter defines that we should call:



      setState(() { _counter++});


      instead of:



      _counter++;
      setState(() {});


      As far as I can see in setState() code, it doesn't use anything that's passed as a parameter anyway.










      share|improve this question














      This question already has an answer here:




      • Why does setState take a closure?

        2 answers




      Why Flutter defines that we should call:



      setState(() { _counter++});


      instead of:



      _counter++;
      setState(() {});


      As far as I can see in setState() code, it doesn't use anything that's passed as a parameter anyway.





      This question already has an answer here:




      • Why does setState take a closure?

        2 answers








      flutter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 22:35









      mFeinstein

      2,17472776




      2,17472776




      marked as duplicate by Rémi Rousselet flutter
      Users with the  flutter badge can single-handedly close flutter questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 13 at 1:59


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Rémi Rousselet flutter
      Users with the  flutter badge can single-handedly close flutter questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 13 at 1:59


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          2














          The end result in release mode is the same.



          But in debug you get an assert for free that checks that the callback inside setState() does not return a Future and it returns immediately.



          But if you are sure the callback is synchronous, the result in debug is the same.






          share|improve this answer





















          • Ok, but I still don't get why to force people to pass something to setState()... If it was called invalidateState() and before calling it we set all the necessary variables, call all the Futures we want, won't it be the same?
            – mFeinstein
            Nov 12 at 23:13












          • Well, they don't force you. It is a best practice to avoid te asynchronous problems. But since you can set it outside and it works, you can do it.
            – chemamolins
            Nov 12 at 23:18


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          The end result in release mode is the same.



          But in debug you get an assert for free that checks that the callback inside setState() does not return a Future and it returns immediately.



          But if you are sure the callback is synchronous, the result in debug is the same.






          share|improve this answer





















          • Ok, but I still don't get why to force people to pass something to setState()... If it was called invalidateState() and before calling it we set all the necessary variables, call all the Futures we want, won't it be the same?
            – mFeinstein
            Nov 12 at 23:13












          • Well, they don't force you. It is a best practice to avoid te asynchronous problems. But since you can set it outside and it works, you can do it.
            – chemamolins
            Nov 12 at 23:18
















          2














          The end result in release mode is the same.



          But in debug you get an assert for free that checks that the callback inside setState() does not return a Future and it returns immediately.



          But if you are sure the callback is synchronous, the result in debug is the same.






          share|improve this answer





















          • Ok, but I still don't get why to force people to pass something to setState()... If it was called invalidateState() and before calling it we set all the necessary variables, call all the Futures we want, won't it be the same?
            – mFeinstein
            Nov 12 at 23:13












          • Well, they don't force you. It is a best practice to avoid te asynchronous problems. But since you can set it outside and it works, you can do it.
            – chemamolins
            Nov 12 at 23:18














          2












          2








          2






          The end result in release mode is the same.



          But in debug you get an assert for free that checks that the callback inside setState() does not return a Future and it returns immediately.



          But if you are sure the callback is synchronous, the result in debug is the same.






          share|improve this answer












          The end result in release mode is the same.



          But in debug you get an assert for free that checks that the callback inside setState() does not return a Future and it returns immediately.



          But if you are sure the callback is synchronous, the result in debug is the same.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 22:48









          chemamolins

          2,0641716




          2,0641716












          • Ok, but I still don't get why to force people to pass something to setState()... If it was called invalidateState() and before calling it we set all the necessary variables, call all the Futures we want, won't it be the same?
            – mFeinstein
            Nov 12 at 23:13












          • Well, they don't force you. It is a best practice to avoid te asynchronous problems. But since you can set it outside and it works, you can do it.
            – chemamolins
            Nov 12 at 23:18


















          • Ok, but I still don't get why to force people to pass something to setState()... If it was called invalidateState() and before calling it we set all the necessary variables, call all the Futures we want, won't it be the same?
            – mFeinstein
            Nov 12 at 23:13












          • Well, they don't force you. It is a best practice to avoid te asynchronous problems. But since you can set it outside and it works, you can do it.
            – chemamolins
            Nov 12 at 23:18
















          Ok, but I still don't get why to force people to pass something to setState()... If it was called invalidateState() and before calling it we set all the necessary variables, call all the Futures we want, won't it be the same?
          – mFeinstein
          Nov 12 at 23:13






          Ok, but I still don't get why to force people to pass something to setState()... If it was called invalidateState() and before calling it we set all the necessary variables, call all the Futures we want, won't it be the same?
          – mFeinstein
          Nov 12 at 23:13














          Well, they don't force you. It is a best practice to avoid te asynchronous problems. But since you can set it outside and it works, you can do it.
          – chemamolins
          Nov 12 at 23:18




          Well, they don't force you. It is a best practice to avoid te asynchronous problems. But since you can set it outside and it works, you can do it.
          – chemamolins
          Nov 12 at 23:18



          Popular posts from this blog

          鏡平學校

          ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

          Why https connections are so slow when debugging (stepping over) in Java?