# Google's Flutter Tutorial- Easily Parse Complex JSON, Create JSON Model Classes, Show in ListView.

Поділитися
Вставка
  • Опубліковано 24 бер 2020
  • Welcome to Flutter tutorial
    This demo helps you to easily parse any complex JSON data in to Dart Model classe easily.
    Proper Error Handling in Flutter
    • #Google's Flutter Tuto...
    Visit coderzheaven.com for more tutorials.
    Please don't forget to LIKE, SUBSCRIBE & SHARE.
    Please leave your valuable comments in the comment section below.
    Thanks for watching.
    Article & Source Code:
    / easily-parse-complex-j...
    or
    www.coderzheaven.com/2020/03/2...
    Follow me on facebook
    / mobile-tutor-299932940...
    Personal Facebook
    / contactvipinvijayan
    Twitter
    @mr_vipin_nair
    More tutorials
    coderzheaven.com
    #fluttertutorials #flutterParseJson #flutterComplexJson

КОМЕНТАРІ • 164

  • @rootom2144
    @rootom2144 3 роки тому +5

    oo bhai jaan bacha li bhai aapne sir ko dikhana tha yrr ye json data parse kar ke. Thank you bhai.

  • @mehdihussain7483
    @mehdihussain7483 4 роки тому +13

    Wow, Thanks for this tutorial! I had been looking for hours on how to parse Complex JSON, and this tutorial was the only one I could find!

  • @siddharthachatterjee9808
    @siddharthachatterjee9808 2 роки тому +3

    This is just the kind of video I had been looking for all this time.

  • @carlosalcaino
    @carlosalcaino 3 роки тому +4

    Thank you so much. My life has just become easier because of this.

  • @philiplartey19
    @philiplartey19 4 роки тому +4

    Another fantastic tutorial. Great stuff

  • @fahadtahir6
    @fahadtahir6 3 роки тому +3

    Wow such a great stuff you have presented and saved my day. Thank you

  • @isururanawaka5839
    @isururanawaka5839 3 роки тому +4

    Thanks. Very clear tutorial.

  • @llama7206
    @llama7206 3 роки тому +3

    Wow this is a great tutorial, I learned so much. Thanks!

  • @viveks.
    @viveks. 2 роки тому +3

    I was looking for the same video. no one explained it so nicely. thanks, man.

  • @EnglishwithYusif
    @EnglishwithYusif 3 роки тому +2

    You made my life much easier!
    Thanks!

  • @dev_casper
    @dev_casper 3 роки тому +4

    Thanks, man. I never followed any modal patterns. But due to the circumstances, I had to come to your video. And it looks like I loved the Modal pattern. Thank you so much for simplifying this. Your video not just taught me parsing JSON but using Modals as well.

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +1

      Great to know that my video helped you. Thanks for watching.

    • @yinkaadeniyi573
      @yinkaadeniyi573 2 роки тому

      Thanks for sharing,immediately i pasted the json map in the model class,i got bunches of error i cant resolve.Is there anything i can do?

  • @leonvanrijswijk8409
    @leonvanrijswijk8409 4 роки тому +3

    Thanks. Very useful and clear explaination.

  • @sanketsheladiya3602
    @sanketsheladiya3602 2 роки тому +2

    Thanks bro...!! really helpful video for freshers

  • @reshnuchandran6698
    @reshnuchandran6698 3 роки тому +3

    Thank you so much .Love from Kerala

  • @staid07
    @staid07 2 роки тому +5

    Great video - very useful. In the try-catch part of the Services.dart file, I had to use return [ ]; instead of List(); Works fine after that.

  • @andrechagas8544
    @andrechagas8544 3 роки тому +4

    Great and easy tutorial. I learned so much in this video and I just say thanks!

  • @martinsuleman1329
    @martinsuleman1329 3 роки тому +2

    Perfect, awesome tutorial man

  • @sterinsaji7310
    @sterinsaji7310 4 роки тому +2

    you are doing a great Job, please keep on doing this great deed.

  • @brightgupta9864
    @brightgupta9864 4 роки тому +2

    Thank you so much. Its helps me a lot. :)

  • @varadgauthankar
    @varadgauthankar 4 роки тому +11

    Finally found the solution after hours of searching, thank you so much;

  • @chaitanyadeshmukh7049
    @chaitanyadeshmukh7049 3 роки тому +1

    thanks bro for making this video you helped me alot .
    keep making such videos .............. :)

  • @PRAMODYADAV-mk7ow
    @PRAMODYADAV-mk7ow 3 роки тому +2

    THANKS FOR MAKING THIS TUTORIAL . PLEASE ALSO ADD ADD TO FAVORITES FUNCTION

  • @princepatel4864
    @princepatel4864 4 роки тому +2

    Very nice video sir 👍👌👍

  • @vipinvijayan7647
    @vipinvijayan7647 Рік тому +2

    Great Great Man.!!!

  • @VJKoding
    @VJKoding 4 роки тому +2

    Thanks you bro,its awesome❤️

  • @igomaur4175
    @igomaur4175 3 роки тому +2

    thank you so much great tutorial

  • @dasunupeshala4713
    @dasunupeshala4713 4 роки тому +2

    Amazing.

  • @tomqin3685
    @tomqin3685 3 роки тому +2

    You save me! Thanks!

  • @nalinwijayasinghe
    @nalinwijayasinghe 3 роки тому +1

    Thank you very much...It was great...🙏🙏🙏

  • @afrospike724
    @afrospike724 3 роки тому +2

    A video on using complex json with https and provider would be appreciated thank you !

  • @user-pan_roman
    @user-pan_roman 3 роки тому +2

    Thank you so much!!!!!!

  • @SaurabhSureshskytz
    @SaurabhSureshskytz 3 роки тому +3

    Thank you so much ! Great Tutorial

  • @learn_with_yvana
    @learn_with_yvana Рік тому +1

    You made my day. Very nice and easy-to-understand tutorial.

  • @divyaratnabhanse4733
    @divyaratnabhanse4733 3 роки тому +2

    Thanks a lot !!!!

  • @Machiuka
    @Machiuka 2 роки тому +2

    Thank a lot for this wonderful tutorial. :)

  • @thatsenam9183
    @thatsenam9183 4 роки тому +1

    Very helpful

  • @varanandasurya1272
    @varanandasurya1272 4 роки тому +2

    Helpful

  • @rodriguenjountsop2848
    @rodriguenjountsop2848 2 роки тому +2

    Thank u very much!

  • @muhammedsanfar2989
    @muhammedsanfar2989 3 роки тому +2

    thank u very much bro

  • @plug_tools
    @plug_tools 4 роки тому +2

    Grate!

  • @bharathshettigar5272
    @bharathshettigar5272 4 роки тому +2

    Thanks sir

  • @shivampokhriyal_
    @shivampokhriyal_ 4 роки тому +2

    Thanks for the Video !!

  • @jameswatson1682
    @jameswatson1682 Рік тому +1

    Excellent Tutorial

  • @raguramanpattusamy9245
    @raguramanpattusamy9245 Рік тому +2

    Thanks 🙏

  • @payelpaul8175
    @payelpaul8175 2 роки тому +2

    thanks man

  • @emranimam92
    @emranimam92 4 роки тому +2

    really easy explanation. Hope you make a video about other http methods like post, put, patch, delete etc.

  • @ganeshrajendran9325
    @ganeshrajendran9325 3 роки тому +1

    It's very useful to me..thank you

  • @esirioneyibo
    @esirioneyibo 4 роки тому +3

    Nice video. Could you please share your vscode settings. I like yours

  • @prajwalpatil489
    @prajwalpatil489 3 роки тому +1

    Awesome 👍

  • @MichalBastrzyk
    @MichalBastrzyk 3 роки тому +2

    Thank you so much.

  • @TheZx9man
    @TheZx9man 3 роки тому +1

    Thank you too -great work, how about get a working Loader instead of the List while loading?

  • @OshiNugs
    @OshiNugs 3 роки тому +2

    Thank you.

  • @jastproo
    @jastproo 3 роки тому

    Could anyone tell me why it change from loading to user when he save the listview ,but not when he save _loading ? .... , or does it need something to trigger the varible to make the function in initstate to run.

  • @user-pm9yi1kt5l
    @user-pm9yi1kt5l 3 роки тому

    How can we make json file with country, state and city names work as an api in flutter, so that aftef selecting country, corresponding states come and then corresponding cities ?

  • @suportera2831
    @suportera2831 3 роки тому

    Do you have any videos that teach you how to pass information from RTDB (Complex) to a list of objects?

  • @mgmyo7066
    @mgmyo7066 4 роки тому +2

    please make a video of api cache example like dio http cache

  • @circket539
    @circket539 3 роки тому +1

    Thanks a lot

  • @ni_kabiu_john
    @ni_kabiu_john 3 роки тому +1

    Thanks man, work just got easier. can you also do a complex json to api

  • @rajansingla5516
    @rajansingla5516 3 роки тому +1

    Thanks for providing the great content! This helps me a lot and saves my time too. I have one question,
    how can we handle the empty fields in the model? Suppose if we get the address fields as null from the api then how can we handle that. The similar case I have stucked in my project. I have a api that contains message, statusCode and data of json type. This is in the case when I have a status code of 200, other than 200 I got values from api i.e. message, statusCode and responseType. So for the status code 200 how can I handle the responseType json because it will not in the response body when status code is 200?

    • @vibhor1386
      @vibhor1386 2 роки тому

      You can add a check like this, if(address!=null) {User(
      myAddress: List.from(json["address"].map((x) => address.fromJson(x))),}

  • @vusumuzichikandi8450
    @vusumuzichikandi8450 4 роки тому +1

    Hi, i have a completely unrelated problem with flutter that i wanted to know if you could help me with. I wasn't sure how else to contact you.

  • @emoconfession11
    @emoconfession11 3 роки тому +1

    noob question, I also like to display the address, how can I do it?

  • @chakrasudarsana5579
    @chakrasudarsana5579 4 роки тому

    Your flutter tutorial is really amazing to learn.But,i don't know How to read local multiple JSON file From assets folder and display data in flutter with Scroll down? Can you say how to do it?

  • @hiteshreddy9807
    @hiteshreddy9807 2 роки тому

    New video should be made considering null safety or the version/sdk should be restricted ( to down grade flutter ) right?

  • @ozonewagle
    @ozonewagle 3 роки тому +3

    help me: The argument type 'String' can't be assigned to the parameter type 'Uri'.

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +3

      Please convert the string to uri using uri.parse

  • @haidersultan7030
    @haidersultan7030 2 роки тому +3

    I am having some issues in my project, may be due to latest version of flutter. It would be a great help if you make a video in new version of flutter.

    • @demodemo9429
      @demodemo9429 2 роки тому

      Yes bro iam aslo facing the same problem...
      I really got irritated from this parsing methods...

    • @haidersultan7030
      @haidersultan7030 2 роки тому +2

      @@demodemo9429 actually I solved this problem --- Try replacing "URL" with "Uri.parse(URL)" this will work, tell me if it does

  • @andika-xb9ie
    @andika-xb9ie 3 роки тому +1

    namosan damet garm khiliiiiiiii khobe site ke gfti

  • @FestusMuberuka
    @FestusMuberuka 4 роки тому +1

    what if i want to list data sorted with user with the most ratings or something like that

    • @MobileProgrammer
      @MobileProgrammer  4 роки тому

      you have to manually sort it in front end which i wont recommend, get it sorted from backend.

  • @lehanmusthafa720
    @lehanmusthafa720 2 роки тому

    Can you please show, how can you do the same with Null Safety...

  • @rodrigoleche3751
    @rodrigoleche3751 3 роки тому +2

    This is cool! Does it work with jsons with data that is constantly updating?

  • @rakeshsharmao8369
    @rakeshsharmao8369 4 роки тому +1

    Thanks for this beautiful tutorial. Very helpful and clearly explained. Json response starting with array works fine. Now some json responses start with braces i.e hash, Following this tutorial for json map gives error. Could you please explain it once. Eg: {"users": [{"name":"Rakesh","age":"25"}, {"name":"Test","age":"12"}], "last_visit_id": "121"}

    • @Snggle
      @Snggle 4 роки тому

      add .toList(), to the end, it will turn it into an array.

    • @varadgauthankar
      @varadgauthankar 4 роки тому

      @@Snggle where should i add this?

  • @AlexanderMazuruk
    @AlexanderMazuruk 3 роки тому +1

    This library github.com/k-paxian/dart-json-mapper has even less boilerplate and more features

  • @chandrumurugan7441
    @chandrumurugan7441 2 роки тому +1

    how to display in scrollview the content

  • @Giigigi1122
    @Giigigi1122 3 роки тому +1

    Cheers! Btw, If I have an ongoing data flow like user is updating their name. Is it possible to adjust only the user name in this case?

  • @bugracakirr
    @bugracakirr 2 роки тому +2

    Is there a json to Dart Converter with null safety supports Json Arrays

    • @bugracakirr
      @bugracakirr 2 роки тому +1

      Sir I did not see your last video about Null Safety. Thanks a lot!

  • @DevMensIT
    @DevMensIT 3 роки тому +1

    How can I access Geo inside Address ?

  • @muhammedaliallaf5076
    @muhammedaliallaf5076 4 роки тому +1

    Thanks for this beautiful tutorial
    Please... How can I Fetch the elements inside address?
    You typed keyword.id for id
    But for the elements inside address??

    • @MobileProgrammer
      @MobileProgrammer  4 роки тому +1

      You can access using the member variables in the Address class.

  • @arthursiloka7437
    @arthursiloka7437 4 роки тому +2

    Hi, this is great tutorial and easy to follow for beginners like me. I have reached 07:18 min in the video VS code is giving an error (Users usersFromJson(String str) A value of type 'Users' can't be assigned to a variable of type 'List'.) Am I missing something? How can I fix this error?

    • @madgamersolid615
      @madgamersolid615 3 роки тому

      I have the same problem. Has anyone found a solution?

    • @xnycker
      @xnycker 3 роки тому

      Stop and reload

    • @adriankadusza8342
      @adriankadusza8342 3 роки тому

      Have you found solution??

    • @gloriachiang9435
      @gloriachiang9435 3 роки тому

      List users = usersFromJson(response.body); //users should be lowercase?

  • @rootom2144
    @rootom2144 3 роки тому +3

    bhai wo hot reload and restart ke liye aapne kaun sa extension use kiya hai?

  • @user-mn8zx6zo5o
    @user-mn8zx6zo5o 3 роки тому +1

    what about local file ??
    not https

  • @rheniumgaming2492
    @rheniumgaming2492 4 роки тому

    Your tutorial is amazing..! Thank you so much. But I'm stuck at 9:07 where you handle with ListTile. The first layer of my complex JSON is a list of car brands. Car brands class has brand name and list of models. how can i print car brands where you printed user names ?

    • @rheniumgaming2492
      @rheniumgaming2492 4 роки тому

      Btw can you make video with Local JSON too ?

    • @MobileProgrammer
      @MobileProgrammer  4 роки тому +1

      you can follow the same method for local json as well.

  • @wowcrafwonderland1674
    @wowcrafwonderland1674 Рік тому

    It was a such a great video, which I was searching for days.
    But I am stuck in Services.dart file
    I'm getting error in.....final List users= usersFromJson(response.body);
    The error is .....A value of type 'User' can't be assigned to a variable of type List.

  • @demodemo9429
    @demodemo9429 2 роки тому +1

    Bro can u pls pls pls a new video parsing nested objects in flutter latest pls I tried many methods but none of them is working .

    • @MobileProgrammer
      @MobileProgrammer  2 роки тому +1

      This video already showing nested object parsing. You can use same method for any object.

  • @gerarddecod
    @gerarddecod 3 роки тому

    how to show sub object json? :s

  • @anuradha7023
    @anuradha7023 2 роки тому

    How to call multiple strings of array in json.... please help us with the answer

    • @MobileProgrammer
      @MobileProgrammer  2 роки тому +1

      Sorry, I couldn’t quietly understand your question. Could you please elaborate?

  • @nguoidungkhac5756
    @nguoidungkhac5756 3 роки тому

    why my load _user.length is null :(

  • @marchheroofbnk48
    @marchheroofbnk48 3 роки тому +1

    My data don't show in my app. Sir

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +2

      Please check the log and see if you have any parsing errors?

  • @paulnoris4928
    @paulnoris4928 4 роки тому +2

    It would be awesome if you made this with a real complex json example something with for example a product > toppings group > toppings:
    {
    "data": [
    {
    "identificador": 1,
    "titulo": "assumenda",
    "titulo_slug": "assumenda",
    "detalles": "Exercitationem deleniti eaque aliquam repudiandae dolor consequuntur accusamus praesentium. Et et recusandae ipsam sequi nulla vel.",
    "estado": "no disponible",
    "imagen": "lm-api-prueba.esy.es/img/27.png",
    "tienda": {
    "identificador": 3,
    "titulo": "Full House Burger",
    "titulo_slug": "full-house-burger"
    },
    "medidas": {
    "data": [
    {
    "identificador": 1,
    "titulo": "molestiae",
    "precio": "133",
    "producto": 1
    },
    {
    "identificador": 2,
    "titulo": "qui",
    "precio": "76",
    "producto": 1
    },
    {
    "identificador": 3,
    "titulo": "nostrum",
    "precio": "91",
    "producto": 1
    }
    ]
    },
    "grupo_ingredientes": {
    "data": [
    {
    "identificador": 1,
    "titulo": "occaecati",
    "tipo": 1,
    "producto": 1,
    "ingredientes": {
    "data": [
    {
    "identificador": 1,
    "titulo": "nemo",
    "precio": 10,
    "grupo_ingredientes": 1
    },
    {
    "identificador": 2,
    "titulo": "eum",
    "precio": 5,
    "grupo_ingredientes": 1
    },
    {
    "identificador": 3,
    "titulo": "sequi",
    "precio": 15,
    "grupo_ingredientes": 1
    }
    ]
    }
    },
    {
    "identificador": 2,
    "titulo": "quae",
    "tipo": 0,
    "producto": 1,
    "ingredientes": {
    "data": [
    {
    "identificador": 4,
    "titulo": "omnis",
    "precio": 10,
    "grupo_ingredientes": 2
    },
    {
    "identificador": 5,
    "titulo": "harum",
    "precio": 5,
    "grupo_ingredientes": 2
    },
    {
    "identificador": 6,
    "titulo": "qui",
    "precio": 15,
    "grupo_ingredientes": 2
    }
    ]
    }
    },
    {
    "identificador": 3,
    "titulo": "et",
    "tipo": 0,
    "producto": 1,
    "ingredientes": {
    "data": [
    {
    "identificador": 7,
    "titulo": "debitis",
    "precio": 5,
    "grupo_ingredientes": 3
    },
    {
    "identificador": 8,
    "titulo": "voluptas",
    "precio": 15,
    "grupo_ingredientes": 3
    },
    {
    "identificador": 9,
    "titulo": "voluptatibus",
    "precio": 15,
    "grupo_ingredientes": 3
    }
    ]
    }
    },
    {
    "identificador": 4,
    "titulo": "error",
    "tipo": 0,
    "producto": 1,
    "ingredientes": {
    "data": [
    {
    "identificador": 10,
    "titulo": "quis",
    "precio": 5,
    "grupo_ingredientes": 4
    },
    {
    "identificador": 11,
    "titulo": "libero",
    "precio": 0,
    "grupo_ingredientes": 4
    }
    ]
    }
    }
    ]
    }
    },
    por example this is only a product, and it have to have multiple models

    • @rakeshsharmao8369
      @rakeshsharmao8369 4 роки тому +1

      Even I need a tutorial on this type of json i.e jsons starting with { instead if [

    • @varadgauthankar
      @varadgauthankar 4 роки тому

      @@rakeshsharmao8369 did you found anything?

    • @abdelrahmanabied5982
      @abdelrahmanabied5982 3 роки тому +1

      @@varadgauthankar
      class Products {
      Products({
      this.data,
      });
      List data;
      factory Products.fromJson(Map json) => Products(
      data: List.from(json["data"].map((x) => Datum.fromJson(x))),
      );
      Map toJson() => {
      "data": List.from(data.map((x) => x.toJson())),
      };
      }

    • @varadgauthankar
      @varadgauthankar 3 роки тому +1

      @@abdelrahmanabied5982 i already came with the solution, but thanks I really appreciate your help.

  • @mergenvadisi2675
    @mergenvadisi2675 3 роки тому

    it's not working for me, sir. I have json data without " [ " " ] " symbols.Could it be because of this? There is no error but data is not coming. If it is, how can i fix my json data?

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +1

      Did you generate the JSON?

    • @mergenvadisi2675
      @mergenvadisi2675 3 роки тому +1

      ​@@MobileProgrammer I added with " echo " and used str replace for fix format in flutter. Now it's working. Thanks, sir.

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +1

      Cool

  • @afrospike724
    @afrospike724 3 роки тому +1

    is anyone else getting a null list when the user is returned ?

  • @wavemusic7153
    @wavemusic7153 3 роки тому +2

    Can we call the api without using .then method and how

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +1

      Yes of course. This is one way. You can use await in front of the calling method when you use it and assign it to your response. That would be much cleaner.

    • @wavemusic7153
      @wavemusic7153 3 роки тому +1

      @@MobileProgrammer can you provide me the code

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +1

      I am using it in my other tutorials.
      Response response = await your call

    • @wavemusic7153
      @wavemusic7153 3 роки тому

      @@MobileProgrammer can you give me that tutorial links

  • @karamatsubhani1368
    @karamatsubhani1368 2 роки тому +1

    data is not fetchable

  • @sdshsjg
    @sdshsjg 4 роки тому +1

    how to do it with local json files ?

    • @MobileProgrammer
      @MobileProgrammer  4 роки тому +2

      You can follow the same method for local json as well.

    • @sdshsjg
      @sdshsjg 4 роки тому +1

      @@MobileProgrammer yeah, i figured it out

    • @MobileProgrammer
      @MobileProgrammer  4 роки тому +1

      Good to hear that.

    • @SamirJzVFX
      @SamirJzVFX 3 роки тому

      @@sdshsjg HOW?!

  • @ishimwesamuel8737
    @ishimwesamuel8737 3 роки тому

    How to handle the errors that comes there after

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +1

      Sorry, I don’t understand what you are saying. Please explain. Thanks

    • @ishimwesamuel8737
      @ishimwesamuel8737 3 роки тому

      @@MobileProgrammer the return in else and the return in the catch block will they return errors if there are errors?

  • @HarshKumar-qw5ou
    @HarshKumar-qw5ou 3 роки тому +1

    No human would type complete statefull widget code, Reveal your Identity traitor(😝).

    • @MobileProgrammer
      @MobileProgrammer  3 роки тому +1

      You should know the basics at the end of the day