Life of a Widget?! | Decoding Flutter

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 พ.ค. 2021
  • Do widgets have lifecycles? What is a widget, exactly? Learn all this and more as we explore what widgets are and how they fit into the Flutter framework.
    Leave us suggestions for code to unravel in the comments below!
    Watch more Decoding Flutter episodes → goo.gle/DecodingFlutter
    Don’t miss an episode, subscribe to Flutter → goo.gle/FlutterYT
    Get started with Flutter → goo.gle/Flutter
    Learn more about the Dart Language → goo.gle/2YF9OCi
    #DecodingFlutter #Flutter #Developer
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 44

  • @1c72
    @1c72 3 ปีที่แล้ว +63

    I think when most flutter devs talk about "lifecycle" they really mean the lifecyle of Elements, because we do use methods such as "initState" and "dispose" etc. So while this video is "technically correct" (which is the best kind of correct), it's not exactly on point to address those questions :|

    • @marflage
      @marflage 3 ปีที่แล้ว

      I was thinking the same. I didn't get your comment though. I got the what we as developers think lifecycle methods are part, but not the lifecycle of an element. I do know however that the Flutter team and we refer to different things with confusingly same names.

    • @noursalman932
      @noursalman932 ปีที่แล้ว

      ​@@marflage Yes the confusion stems from the fact that the word "widget" is sometimes used for "static configuration of UI elements i.e recipe" and other times for the elements themselves.

    • @DangHoang-di3gk
      @DangHoang-di3gk 10 หลายเดือนก่อน

      agree

  • @sibylsystems5771
    @sibylsystems5771 3 ปีที่แล้ว +34

    After opening 20 tabs in attempt to understand widget lifecycle today, they post this and it's not even detailed :(
    I suppose their mindreading abilities are not omnipotent

    • @loganrussell48
      @loganrussell48 3 ปีที่แล้ว +10

      What more do you need to know? The last sentence seems to make it clear: widgets don't have a lifecycle. They are either built, rebuilt, or not used.
      During the building process, flutter calls the build method. When it's rebuilt, it just calls the build method again. When it's not used, the build method isn't called at all.

    • @niggelgame
      @niggelgame 3 ปีที่แล้ว +5

      @@loganrussell48 well there is state and the Lifecycle of a therefore StatefulWidget. I know that this is the States Lifecycle, not the Widgets, but especially for new Flutter Devs, this video will probably only be confusing

    • @hyungtaecf
      @hyungtaecf 3 ปีที่แล้ว

      @@niggelgame The states are no widgets, they are classes that help to keep state of variables, but every time it rebuilds, it rebuilds other widgets, never the same ones…

    • @loganrussell48
      @loganrussell48 3 ปีที่แล้ว +1

      ​@@niggelgame Even with a stateful widget, the widget doesn't have a lifecycle. A new version of the same type of widget will be built by calling the build method again, with the same mutable state class. It is the changing state class that actually makes the application useful. You can think of the build method as a sort of transformer that takes a data model (state) and transforms it into a usable piece of the application using the build method.
      Again, there is no lifecycle. Just build methods. Supply something different to the build method, get a differently configured widget returned from the method.
      When you want to change the widget, change the state of the widget using setState and the widget will update the state, and then the build method will be called again, to generate a new widget, which will fall into the same spot in the widget tree as the last one.

    • @niggelgame
      @niggelgame 3 ปีที่แล้ว

      @@loganrussell48 yes, that’s what I wanted to say, but I didn’t really. My point was, that for new Devs, the State, which has some sort of Lifecycle, is directly coupled with a StatefulWidget, which may imply a StatefulWidget Lifecycle. That is what I thought until I started taking a closer look at Flutter itself and it is probably what many others think too, which could make this video seem confusing

  • @bbzz
    @bbzz 2 ปีที่แล้ว +3

    It's still a popular question on the interviews. I always try to tell them that there is no lifecycle but they just count is a wrong answer. One of them even started explaining me why I'm very wrong thinking that there is no lifecycle

  • @idapro9847
    @idapro9847 3 ปีที่แล้ว +11

    Story about the cake is messed up

  • @chancefinley2432
    @chancefinley2432 3 ปีที่แล้ว +15

    Not sure the analogy sunk in easily

    • @marflage
      @marflage 3 ปีที่แล้ว

      It did not for me. But basically what was conveyed was that every element is rebuilt from the ground up every time there is a change in the state of the current view.

  • @dephinera3502
    @dephinera3502 3 ปีที่แล้ว +37

    That cake analogy was too abstract... Am I the only one who expected something more technical?

    • @FlutterKids
      @FlutterKids ปีที่แล้ว +1

      I think it makes the video more accessible to different skill levels. If more people can understand the video, doesn't that make it better? 🤔

  • @franklinoladipo2343
    @franklinoladipo2343 3 ปีที่แล้ว +4

    Nice video. But how about widgets that extends StatefulWidget, do they have a lifecycle(since you can override initState, dispose, etc) ?

  • @user-tv4kh4pc7s
    @user-tv4kh4pc7s 3 ปีที่แล้ว +3

    Cool title Sound! Like from Santa Barbara series 1984

  • @anmolkapoor1068
    @anmolkapoor1068 3 ปีที่แล้ว +1

    Nice work

  • @rebarius
    @rebarius 3 ปีที่แล้ว +16

    that was a kind of abrupt end at the end :D maybe a little bit more transition with the bg-music :)

    • @eliteelitebob
      @eliteelitebob 3 ปีที่แล้ว +1

      Huh? It seems fine to me. Did they update it?

  • @khairulanas
    @khairulanas 3 ปีที่แล้ว +3

    i love new music background

  • @iilhamwd346
    @iilhamwd346 3 ปีที่แล้ว +5

    Out of topic but i got uncomfortable when seeing animation at 2:05 😂

  • @ItsLarry
    @ItsLarry 3 ปีที่แล้ว

    Nicely baked video 😉😂

  • @heshansandeepa9471
    @heshansandeepa9471 ปีที่แล้ว +1

    Very nice

  • @francisgeorge7639
    @francisgeorge7639 3 ปีที่แล้ว +1

    Don't we learn this pretty nearly out of the gate when first learning about flutter? The problem is the subtle code-interactions between the immutable Widgets and the underlying mechanisms that are explained in impenetrable engineer-speak in the docs. Really I would like to read the source to get a handle on it, but the source is practically unreadable due to the amount of asserts. The flutter plugins to Android Studio etc need a "hide asserts" option.

  • @larsien85
    @larsien85 2 ปีที่แล้ว +1

    He said in last time, "Widget is either build, rebuilt or not used at all".
    Anyone explain why he said "not used at all"?
    I guess it means if the widget is already built once then it located in memory and displayed by variable state.
    Do I get it?

  • @ehsanhasin8092
    @ehsanhasin8092 ปีที่แล้ว

    thank you for your example 🥞

  • @OsamaAsif
    @OsamaAsif 3 ปีที่แล้ว

    Cool🔥

  • @Smongo412
    @Smongo412 3 ปีที่แล้ว +1

    Flutter is very intuitive for a React developer like me

  • @user-hy9gb9np6j
    @user-hy9gb9np6j 5 หลายเดือนก่อน

    Aren't the videos in this playlist in reverse order? The last video in the playlist is "Introducing Decoding Flutter".

  • @thephenomenal9348
    @thephenomenal9348 3 ปีที่แล้ว +4

    Make installation Of futter smooth and flexible like installation of all files in other drive in just on folder with nested folder. Give options to completely installation of gradle, SDK, emulator, plugin in one folder with flexibility to choose drive.

  • @UsamaKarim
    @UsamaKarim 3 ปีที่แล้ว

    We might understand it well if we came from Android or iOS

  • @yosoydeux
    @yosoydeux 3 ปีที่แล้ว +1

    Me gustaría una forma de que mi aplicación recibiera eventos desde TH-cam, ¿alguien me puede ayudar?

  • @youdube1203
    @youdube1203 2 หลายเดือนก่อน

    so Element is responsible for rebuild and update state

  • @georgemuigai9035
    @georgemuigai9035 2 ปีที่แล้ว

    cool.

  • @clarkkent1473
    @clarkkent1473 2 ปีที่แล้ว

    TIMEY WHIMEY WOBBELY STUFF !!!!! DOCTER WHO

  • @BrendansReasons
    @BrendansReasons 2 ปีที่แล้ว

    I'm gonna have to say no to this jingle

  • @zulfiqarawan3407
    @zulfiqarawan3407 3 ปีที่แล้ว

    Kind of Right. But incomplete.
    Widgets are immutable but element is mutable and kind of lifecycle of widget

  • @MichaelLinggardjati
    @MichaelLinggardjati 3 ปีที่แล้ว

    I WANT IT BOS

  • @katekko1
    @katekko1 3 ปีที่แล้ว +1

    :o

  • @md.rahamatullah4808
    @md.rahamatullah4808 3 ปีที่แล้ว +1

    :)

  • @pedropeterle6380
    @pedropeterle6380 3 ปีที่แล้ว +1

    frist