Flutter Json Serializable & Build Runner Tutorial | Flutter Package

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you like our video please share like and subscribe to our channel hi welcome back to my channel today i'll be showing you how to use json serializable and build runner package in flutter before we start the tutorial let me briefly describe what is json serializable all data that transfer or receive from backend are in the form of json which basically json is a key value structure so in order for you to use the key value structure or json in your front-end app more flexible you should serialize it into a data class and today's tutorial on json serializable package in flutter will help you solve all the problems now let's input the package in the flutter project you just have to add the package into pubspec.yaml file to make sure no any error happens i would suggest to follow the package version that i use in current tutorial [Music] in this tutorial i will be creating a sample data class you should customize the data class based on your json [Music] [Music] so now i have created a user class with name address and age as the variable and a constructor next we will be creating a factory function that helps us map the json received from the http request to this class [Music] [Music] [Music] [Music] two functions are needed one is from json and one is to json now the data class is finished but as you can see there are the red underline at the functions it means that the function something is missing but actually this is not missing here introduce a build runner package that we imported earlier on in prospect.yml the build runner helps us to generate the function code and reduce our boilerplates so to let the build runner package know that it needs to generate code for this file we need to add part and the file name now we can run this command in the terminal to generate the code [Music] [Music] now you can see a new user dot g dot dot file is created the name is same as the name that you gave after the part and the error now disappear from the user data class factory function so now we can use user dot from json function to serialize the json that we received from http request so that's all for today's tutorial if you would like to know how to call http request please check out my dio http flutter package tutorial if you like our video please share like and subscribe to our channel see you next time [Music] [Music] do [Music] you
Info
Channel: AI with Flutter
Views: 11,710
Rating: undefined out of 5
Keywords: flutter json serializable, flutter json parsing, flutter json to data model, flutter json serialisation, flutter build runner, flutter build runner delete conflict, flutter build runner json, flutter json serialisable tutorial
Id: rgxg9PG_3ZA
Channel Id: undefined
Length: 7min 44sec (464 seconds)
Published: Sun Aug 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.