Flutter Dynamic List with Provider

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video i'm going to show you how to make a dynamic list using the provider package i already added the provider to the popsicle file i will start with a model class and i will name it dynamic list it's going to have a list field i will pass it to the constructor and i will also write a get method to access in other classes after that i will write the provider class it is going to be list provider with change notifier it is going to have a list field and add method and a remove method what we should pay attention is to add modify listener at the end of the methods so now i will wrap the my homepage class with change notifier provider it is going to return a list provider value after doing that we are done with setting the provider now we will move on to the home page class as you can see i already brought the template of the homepage i will get the list elements in a form and the form needs a key we also need a text editing controller to get the value now we already inserted our provider widgets and in order to use that i will declare a variable task item and initialize all these in in its states when initiating the provider i will pass false to the listen parameter in order to avoid unnecessary rebuilds and controller needs to be disposed in the dispose method now i will pass the key to the form and controller to the text form field in the text form field we will have the onsave and the validator methods in unsaved we will call the add item method from our list provider class in validator we will check if the text form field is empty or not in the elevated buttons on pressed method we will check if the current state of the form is validated or not if it is we will save the value now we will wrap the list with consumer so that only the list will be built when an item is added in our build list method we will return a dismissable widget and we need to generate a unique key value for dismissible widgets and in order to do that i will declare a counter value and each time this field list method is invoked the counter value will be incremented i will also declare a dynamic list object to add the values to the list in our model class back to our method dismissible will have on dismissed method in this method we will call the delete item method from our provider class all right we got an error let's see why it is popped up well we forgot to create the dynamic list object let's do it in the united states now we have another error well we got that error because we didn't specify the item count in our list field now we don't have any errors let's see if it is working properly so that's all for this video i hope you liked it don't forget to subscribe to my channel and like the video for more videos see you next time
Info
Channel: Mehmet Fatih Erdem
Views: 16,941
Rating: undefined out of 5
Keywords: flutter, dart, android, ios, mobile app development, programming, tutorial, course, udemy, coding, provider, dependency injection, state management, flutter tutorial, flutter tutorial for beginners, flutter for beginners, dart tutorial, dart and flutter, dart flutter, dart tutorial for beginners, flutter vs react native, flutter introduction, intro to flutter, install flutter, windows flutter, how to install flutter, install dart, flutter doctor
Id: NOrUazt9vNI
Channel Id: undefined
Length: 12min 26sec (746 seconds)
Published: Tue Mar 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.