How Flutter renders Widgets

Поделиться
HTML-код
  • Опубликовано: 30 июл 2024
  • At Google Developer Days China 2019, Andrew Fitz Gibbon and Matt Sullivan discuss how Flutter works under the hood, and dig deep into widgets, elements, and render objects. Stay tuned to gain a better understanding of Flutter, and build better apps!
    GDD China 2019 → goo.gle/2WMctu8
    Flutter Create → goo.gle/2WNaG85
    Learn everything about Flutter at → flutter.dev
    Subscribe! → goo.gle/Flutter

Комментарии • 116

  • @jesselima_dev
    @jesselima_dev 4 года назад +97

    This is by far the best explanation about how Flutter render the UI. So, the secret of its performance is not only the Skia but also the application architecture and the amazing reuse of render objects. This is an outstanding work the Flutter team and community have made.

    • @HermanWillems
      @HermanWillems 4 года назад +13

      It's almost the same architecture as QT Quick. Only with different words. QML is a markup language that describes your UI, then you have a node of QQuickitems, and QSGNodes (which is the RenderObject here). And then with QT Quick it goes to OpenGL for fast rendering. It also only updates what changes, and doesn't change the widget. It's also super performant just like Flutter. And was here before. Have you ever been in a Tesla Model S or 3 or any Tesla? This whole UI = QT Quick. QT uses QML+Javascript on top. Where Flutter uses Dart (For both markup & scripting) Did you really think this is new technology? They just took that idea, and copied it... And for Skia, QT uses Qpainter which both have similar backends(for example OpenGL).

    • @jesselima_dev
      @jesselima_dev 4 года назад +1

      @@HermanWillems Nice info!!!!

  • @SuperSomeguy56
    @SuperSomeguy56 2 года назад +19

    I've been working on a passion project written in Flutter for quite a while. I've gained understanding of how it works under the hood by reading source code, but I've always had gaps and questions. In 26 minutes, Matt and Andrew taught me more about the framework than I've learned on my own in all that time. I want to thank Matt, Andrew, and the entire Flutter team for producing and publishing these instructional videos. The entire Flutter community is better for it.

  • @whitemagehealing8126
    @whitemagehealing8126 2 года назад +9

    This is a much needed foundational explanation! Thank you for taking the time to create it!
    In my beginner brain, it sounds like they are saying, well, just use the Widget tree and don't care if you duplicate stuff, because we will figure how that stuff is different in the Element tree for you and tell the RenderObject tree if anything needs to be done. So just concentrate on Widgets and "forget" about the other stuff.

  • @taufiqrahman2363
    @taufiqrahman2363 4 года назад +51

    Thank YOU the Flutter team for such a beautiful tool! Its a real beauty!

  • @njeunkweborel866
    @njeunkweborel866 Год назад

    Thank you Andrew and Matt for this helpfull presentation of the process flutter use to manage and render elements on the UI.

  • @akbarmasterpadi
    @akbarmasterpadi 2 года назад

    yes , the concepts was very clear , the flutter architecture was awesome , it gives the apps work faster , great work flutter team

  • @shubhamjalan2440
    @shubhamjalan2440 2 года назад +7

    @Flutter team: The video starts by explaining the solution, without explaining the actual problem which the architecture is supposed to solve, and what were the alternative architectures, and why this particular architecture was chosen by the flutter team. Would be enlightening, if you can make a video on that.

  • @jaydangar7897
    @jaydangar7897 4 года назад +1

    Thanks for the clear explanation.

  • @zesegatto
    @zesegatto 3 года назад +4

    Nice! Somethings are making senses to me now...

  • @htetlynnhtun101
    @htetlynnhtun101 3 года назад

    The explanation is superb.

  • @ninjacoder620
    @ninjacoder620 Год назад +2

    Explained very nice , thank you !

  • @satishkumar-qq8df
    @satishkumar-qq8df 2 года назад

    Such a wonderful video, thank you so much.

  • @A_I_GHOST
    @A_I_GHOST 3 года назад +2

    When the element and render object are going to be destroyed(GC) when the widget tree structure isn't changed?
    For example, if you have PageA pushes PageB then pops PageB. I am guessing even you have popped PageB, but the render object and element won't be destroyed because they are still hanging to wait for another instance of PageB, so they can update the view correctly and efficiently? Is this right?

  • @falkmuller232
    @falkmuller232 2 года назад

    Very interesting! Great presentation!

  • @abhilashchandran3126
    @abhilashchandran3126 4 года назад +1

    Finally this video is available.. YAY...

  • @ryannayak5797
    @ryannayak5797 3 года назад +2

    thankyou for this!!

  • @user-gu5ts5nx8r
    @user-gu5ts5nx8r 3 года назад

    Very helpful, thanks for sharing

  • @malikkurosaki
    @malikkurosaki 4 года назад +2

    Flutter is very difficult in the beginning, but after learning, flutter is very amazing and easy

    • @vladarskopin3314
      @vladarskopin3314 2 года назад +3

      That's exactly what I'm feeling about it :)

  • @ymm3282
    @ymm3282 3 месяца назад

    Thanks a lot!It really helps!

  • @user-sc7tq2di7q
    @user-sc7tq2di7q 2 года назад

    Amazing, Thanks Flutter 💙

  • @user-dx4iv4qu7u
    @user-dx4iv4qu7u 3 года назад

    Thank you! It is a nice video.

  • @KuroManX
    @KuroManX 2 года назад

    Very good explanation, thanks!

  • @jishnuanchery
    @jishnuanchery 3 года назад +1

    Thank you!

  • @lelandreardon7844
    @lelandreardon7844 Год назад +3

    This video explains how widget replacement is performed, but what happens if I insert a widget into the tree?
    If I have tree A->B->C->D and insert widget E (say, a container) like so: A->E->B->C->D, how will Flutter react when it reaches widget E? Will it destroy the tree and widgets, elements, and render objects of "B, C, and D", or simply 'unlink' them, but keep them around in memory, and search through that pile of widgets on the side each time as it continues building the widget tree? Would that be facilitated by the widget keys, similar to the 'canUpdate' method? Then, does it clear that memory pile after finishing the whole tree update?
    If anyone knows a good resource for further explanation, could they share?

  • @songzh2911
    @songzh2911 14 дней назад

    great video!!

  • @kosukesaigusa8262
    @kosukesaigusa8262 3 года назад +4

    Very helpful video, thank you so much! Just one question, I find "RichText" widget extends "MultiChildRenderObjectWidget" in the source code (basis.dart), but is it correct it creates LeafRenderObjectElement the guy is talking around 9:27 ? Should it be MultiChildRenderObjectElement...?

    • @Dhruvam
      @Dhruvam Год назад

      You are right, RichText showuld create MultiChildRenderObjectElement

  • @heysuvajit
    @heysuvajit 4 года назад +2

    Hopefully RUclips will provide realtime video translation in future

  • @jvkob7146
    @jvkob7146 8 месяцев назад

    nice explained

  • @lone.wo1f
    @lone.wo1f 4 года назад +1

    Man timing! Turned off my wifi and at the same time this notif came! Gotta come back

  • @officialismailshah
    @officialismailshah 2 года назад

    awesome talk.....

  • @ezequielsosa1581
    @ezequielsosa1581 3 года назад

    Thank You!

  • @tuitree
    @tuitree 2 месяца назад

    This is great!!!

  • @_Alan
    @_Alan 4 года назад

    great talk

  • @officegarapin2957
    @officegarapin2957 2 года назад

    Thank you so much

  • @NomanAmeerKhan
    @NomanAmeerKhan 4 года назад +23

    If every thing in flutter is widget then why are not they counting TextSpan object as Widget in sample code its constructor is called but still not counting?

    • @hossamelsayed4441
      @hossamelsayed4441 3 года назад +1

      same question

    • @OliverRhyme
      @OliverRhyme 3 года назад +3

      TextSpan is just a container for the data. Its only job is to encapsulate strings and how they are annotated. Not literally all in flutter is a widget, some are data classes, and many others which is a feature of dart being object oriented language.

  • @mikoaj1954
    @mikoaj1954 2 года назад

    very informative

  • @RishiRaj-dl1mg
    @RishiRaj-dl1mg 4 года назад

    Can anybody tell what's the lifecycle of a flutter application. Is it can update, createRenderObject and updateRenderObject??

  • @mariamalbarghouti4385
    @mariamalbarghouti4385 3 года назад

    Thanks💙

  • @DPrOdiGiO
    @DPrOdiGiO 4 года назад

    why flutter web use only canvas for rendering? its too heavy compare to html and css style!

  • @huiliu-lo2og
    @huiliu-lo2og Месяц назад

    thank you

  • @krokenstiv8777
    @krokenstiv8777 Год назад +2

    very good!

    • @flutterdev
      @flutterdev  Год назад +2

      Thanks, Kroken! We appreciate you!

  • @DTrain4711
    @DTrain4711 4 года назад +11

    I don't understand that video :-( !
    I know, how to use flutter, i know how games normally work, know many ways to manage the states in flutter and dart, but i dont't understand, how flutter really works. I.E. I can Not say, when flutter redraws my widgtes.
    Please make another video for that ;-)

    • @thatcaligula
      @thatcaligula 3 года назад

      I agree the video is not complete but at least gives the idea of this kind of layering used to manage widgets and UI. Many more things could be explained about this topic like how you actually update a widget and how that affects the three trees, etc. I find useful to use OOP concepts to explain the structure, for example that the Widget is the class/object definition and the Element is the object instance which instead of being destroyed every time can be updated with new properties (and the Render element just draws it). So if you create a new instance of an object (a ui basic widget) Flutter will try to find an existing running instance in the tree to reuse instead of reinstantiating the object, that saves a lot in terms of performance, no need to destroy+construct but just update properties. Hope it can help.

  • @mamadoualioubah1186
    @mamadoualioubah1186 4 года назад +4

    Recylcing as much as possible, flutter is actually saving the planet cause it doesn't pollute there does not produce waste lool

  • @yourfellowmuslimyagi2065
    @yourfellowmuslimyagi2065 Год назад +1

    Excellent presentation

  • @pradeep422
    @pradeep422 4 года назад

    Awesome...

  • @marcom.
    @marcom. 2 года назад +3

    Sorry guys, but this doesn't explain things quite well. Why are the widgets immutable? If they weren't, you wouldn't have to throw them away and could unite them with the element tree. And then you would end up with a 2-peer-architecture like Java Swing did: Swing had the logical components tree and the UI-Render-Objects tree. And an update to a logical component would only update it's UI-Render-Object. And you could change sub-trees (i.e. re-parenting) without creating any new objects. So I don't get the point why you made a third immutable layer.

  • @Verrisin
    @Verrisin 2 года назад

    so, widgets are like typed Props (except they define what "component" to use)
    and Elements are like Components
    and the rendering part is just different...
    (when comparing it to React)

  • @hollycow8171
    @hollycow8171 Год назад +1

    1:23 Isnt it 3 WIDGETS ? Center, RichText and TextSpan ?

  • @yomaru_1999
    @yomaru_1999 3 года назад +4

    thanks flutter team for the explanation. Flutter behind the scene mechanism always seems like a myth to me. But what if we change a parent widget, will the render object of it child widgets be removed as well? Or flutter is clever enough to know that the child are not changed so it simply remove the parent render object but keep the child render object and then build a new parent render object and link them back?

    • @luisonio11
      @luisonio11 2 года назад +1

      That is a good question, do you got an answer in the last year for that question? 😅

  • @jonomozzy2169
    @jonomozzy2169 Год назад

    Few minutes of your presentation, and all those hours of tutos + books read make more sense ;) you guys really have a knack for those analogies, much like a mother bird chewing up some worms for her newborn helpless chicks :D Ive been struggling to get a firm answer, or find a soution for that matter - Is it possible to have a dynamic form, in so far as the number of fields as well as each fields type would only be known at runtime - for EG: could be a text / date picker / checkbox or multi-select.. In angular i would achieve this through its FOR & IF directives in the View itself, inserting all field types hidden by default, and conditionally unhiding & assigning to each of the models values/fields. If that makes sense. Is there someway similar could be achieved one way or another in Flutter ? Thanks in advance, & best regards

  • @PhilippKeller
    @PhilippKeller 2 года назад

    I'd wish they covered Skia canvas and what happens on Android vs iOS

  • @deepak5283
    @deepak5283 4 года назад

    sir when i have run flutter app in emulator,it runs correctly .when i see a emulator the app size is 97 mb,the app size is large .i have doubt if i use flutter for my project app size it would bigger ,
    how to use flutter to develop big project

    • @abdoufma
      @abdoufma 4 года назад +1

      Depends on what you're doing, but you're most likely running the debug APK which is several times bigger than the release APK.
      Also, the relative differences in APK size would likely be smaller with larger apps, since Flutter's overhead size is fixed (~4Mb)

    • @donghyunshin21
      @donghyunshin21 2 года назад

      Proabably running in debug mode

  • @heshansandeepa9471
    @heshansandeepa9471 2 года назад +1

    very nice

    • @flutterdev
      @flutterdev  2 года назад +1

      A big thanks to you, Heshan! We appreciate your continued support 😄

  • @easthvan
    @easthvan 11 месяцев назад

    "No Directionality Widget found" error if you run the code from the very first slide...

  • @ehsanhasin8092
    @ehsanhasin8092 Год назад

    that's great

  • @viditkhanna3721
    @viditkhanna3721 3 года назад

    It still not has a widget like Recycler View from Android.

  • @haniyasin3650
    @haniyasin3650 2 года назад +3

    something has gone way wrong in web and mobile development in recent years, engineers must step in to fix this mess

  • @gokulakrishnan1977
    @gokulakrishnan1977 4 года назад +13

    Supporting regional language is good thing. But we need translation. Can you please upload English version of slide and put it on description ❣️.

  • @ben6
    @ben6 4 года назад +2

    Why is the element or render object an expensive thing to generate, and skipping them makes it much faster? I feel like this wasn't answered, yet this is the fundamental assumption that needs to hold for this rendering to be efficient.

    • @admniyeokuyorsun...3044
      @admniyeokuyorsun...3044 4 года назад +1

      Because each rendering takes cpu and gpu load and when you render already existing objects, the real part to update takes significantly more time compared to skipping, and overall cpu gpu load increases and battery drains faster. Even though we are talking about maybe like miliseconds for small apps, why would you render 100 objects when you only changed one of them and that is the only thing to be updated ? There is no advantage of rendering everything again and again in lets say each keypress

    • @midsummerstation3345
      @midsummerstation3345 2 года назад

      @@admniyeokuyorsun...3044 but why do you need the widgets and elements tree for that. You can just calculate what's changed when a new widget is passed and update the render object directly

  • @goodprogrammer
    @goodprogrammer 3 года назад +3

    The rendering tree logic essentially looks like in React

  • @thanhtrancong4554
    @thanhtrancong4554 4 года назад

    Hopefully, Flutter team share slide.

  • @lianaigushi
    @lianaigushi 3 года назад

    why can't use widgettree+rendertree ? still not get the necessity of element tree .

    • @KuroManX
      @KuroManX 2 года назад +1

      The context is on the element tree, so the element tree tells others widget where they are.

  • @leitheoleu5451
    @leitheoleu5451 Год назад

    Isn’t it just dom diffing? Does React Native do the same thing?

  • @JkeyKong
    @JkeyKong 4 года назад

    1st programming step, Hello China

  • @serveroverload-1
    @serveroverload-1 3 года назад +1

    React does the same thing using virtual dom and diffing.

  • @yeyadesire
    @yeyadesire 4 года назад +26

    Great talk, but Chinese is a bit confusing 😕

    • @carpedukem
      @carpedukem 4 года назад

      Very true

    • @PaulKazo
      @PaulKazo 4 года назад

      So because of some Chinese titles you missed the whole point?

    • @yeyadesire
      @yeyadesire 4 года назад

      @@andrewfitzgibbon3236 much better now, thanks :)

    • @pizza_and_love
      @pizza_and_love 4 года назад

      @@andrewfitzgibbon3236 Could you tell us where can we get the slides? Thanks a lot!

  • @gang_albanii
    @gang_albanii 4 года назад +2

    video with english title that contains chinese texts. very smart

  • @nikhilbadyal
    @nikhilbadyal 3 года назад +2

    This is cool and i already invested a lot of time learning this cool lang.😇 i hope they will not kill the project after few years. As they are trying to cover more and more platforms which needs more and more human resources. And if the project wont generate any fruitful result/revenue. They gonna kill the project like the stadia. 😏

  • @WhatIsThisAllAbout
    @WhatIsThisAllAbout 4 года назад +1

    2:51 before watchign this video i watched soem spiritual/philosophical content.

  • @MPRGyanStudio888
    @MPRGyanStudio888 2 года назад

    How to add blender animation in flutter apps

    • @flutterdev
      @flutterdev  2 года назад

      Hello, Parshuram!
      Great question!
      We think you might find the following link useful:
      goo.gle/3S4vPa8
      Hope this helps 😎

  • @Hassan-bd4vu
    @Hassan-bd4vu Год назад +1

    This is great 🐦

  • @Code_School
    @Code_School 4 года назад +1

    I in love with you #Flutter

  • @Timepass_duniya
    @Timepass_duniya 3 года назад +1

    Why you are in china ?

  • @probably_not_a_bot
    @probably_not_a_bot 4 года назад

    Quick question: Any downsides of this?

    • @HermanWillems
      @HermanWillems 4 года назад

      Not native GUI, OS cannot hook into GUI, accessibility. etc. There is no silver bullit. But hopefully they will adress accessibility at least!!! And they try to copy native GUI, to be close to the real thing.. But it's fake. Also OS hooks into the GUI is a difficult problem and needs "if solved" to be updates by every OS update.

    • @sadhlife
      @sadhlife 4 года назад

      @@HermanWillems google has decided to take the "update itself on every OS update" task, so we don't need to worry about that, and OS hooks can always be provided by native written packages or including native code when necessary

  • @eliasayele1102
    @eliasayele1102 4 года назад

    i am waiting for nihow animation

  • @WilsonSilva90
    @WilsonSilva90 Год назад

    Does Flutter still behave this way?

  • @carpedukem
    @carpedukem 4 года назад +1

    Next presentation in wingdings fonts please

  • @fullemptiness
    @fullemptiness 4 года назад +1

    I think they had replaced the Chinese text with English text, I don't know how, but wow, thannks, I came here before when it was Chinese, and left miserably

  • @user-hs7fi9vr8k
    @user-hs7fi9vr8k 9 месяцев назад

    这个演讲是在上海?中文讲这个的太少了,视频更是没有。只有来这里看视频才了解到了flutter渲染的原理(或者说是3颗树的设计目的?),26分钟的视频我看了快一个小时,看一句就暂停一下看英文字幕,谁叫英文学的是哑巴英语😂 (机器翻译还是有问题,有些地方不够准确)

  • @laujimmy8635
    @laujimmy8635 4 года назад +2

    That simple code will crash due to "No Directionality widget found"

    • @vanking8384
      @vanking8384 3 года назад +2

      You should add " textDirection: TextDirection.ltr," in the TextSpan

    • @laujimmy8635
      @laujimmy8635 3 года назад

      @@vanking8384 ah, I see. Thank you

  • @tananga1523
    @tananga1523 3 года назад +1

    Isn't that funny: China is blocking Google and Google makes special event for China. So sweet

  • @user-fg5rf8wf7f
    @user-fg5rf8wf7f Год назад

    你好

  • @tobyying1955
    @tobyying1955 2 года назад

    ni hao~

  • @michelfeinstein
    @michelfeinstein 4 года назад +1

    Can't you edit the video and translate the Chinese text? At least add subtitles

  • @ThijsAarnoudse
    @ThijsAarnoudse 4 года назад +4

    It would be a great talk if I can read Chinese but now it is just your speech and thus harder to follow

  • @MrShurminator
    @MrShurminator Год назад +1

    Shows how inefficient Flutter is with memory management when it comes to memory constrained devices... An overengineered mess, which will hopefully change in the future. This tongue-in-chick presentation does not justify the unnecessary 3 layers of UI rendering pipeline. dotNET went through the same mess of a UI in early days, and it was a memory hog like Flutter still is. Immutable UI design is the worst approach - I am surprised the brains at Google went that route. Every 5 years the wheel has to be reinvented it seems.

  • @noninvasive_rectal_probe8990
    @noninvasive_rectal_probe8990 7 месяцев назад

    All of that feels unnecessarily convoluted. So far I am more confused about how I would create a custom layout for Widget's when I am in something like a RenderBox

  • @abson-su2nz
    @abson-su2nz 2 месяца назад

    你好