icon Captions
Loading subtitles...

Flutter ValueNotifier and ValueListenable builder | Flutter Apps | const nishit

youtube translate youtube translator youtube transcript youtube subtitles translate youtube to english youtube translate to english youtube video translation

YouTube transcript, YouTube translate

32/32

A quick preview of the first subtitles so you know what the video covers.

hello people this is necessity and in this video i am going to show you how you can use value listenable builder and avoid using set state so as you can see here this is just a basic counter app so first what i will do i will replace the set state method with values enable builder and later in the video i will also show you how you can take input validation using value listenable builder so it will make our code more optimized and it will reduce all the unnecessary builds so this is the project and this is the basic app that we get when we create a new project it's a basic counter app let me align both of these windows alongside okay so i have removed all the comments but you can see there are only two commands left in our code first in this blog increment counter that using the set set will call build method again and again and will rerun the build method every time we call search state the same thing is written inside of build so basically a build method is the responsible widget is the responsible method that creates the widget for us that creates the ui of whole screen for us so we don't want the complete screen to rebuild every time we set state what we can do is we can avoid using set state and we can use value listenable builder so to see it in action i am just going to print something in here inside of build method so that every time i set the state you can see the build method gets rerun so increment counter using the set state it will call the build method again and again so as soon as i press the button you can see build method call gets printed this is just because of set state okay now we have seen we have got to know that how it is affecting the performance because a layout can have many elements on the screen and that all elements will get rebuilt every time we set the state just to remove the set state we don't need it here now and if i read the restart the app and now

Settings

100%

Target language

🔊 Audio Playback
Playing translated audio