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

Поделиться
HTML-код
  • Опубликовано: 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.

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

    Another fantastic tutorial. Great stuff

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

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

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

    Thanks. Very clear tutorial.

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

    You made my life much easier!
    Thanks!

  • @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.

  • @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?

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

    Very nice video sir 👍👌👍

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

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

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

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

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

    Thanks. Very useful and clear explaination.

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

    Amazing.

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

    Thank you so much .Love from Kerala

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

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

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

    Perfect, awesome tutorial man

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

    Great Great Man.!!!

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

    thank you so much great tutorial

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

    Thanks you bro,its awesome❤️

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

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

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

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

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

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

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

    You save me! Thanks!

  • @user-pan_roman
    @user-pan_roman 3 года назад +2

    Thank you so much!!!!!!

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

    Helpful

  • @sanketsheladiya3602
    @sanketsheladiya3602 2 года назад +2

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

  • @PRAMODYADAV-mk7ow
    @PRAMODYADAV-mk7ow 3 года назад +2

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

  • @rodriguenjountsop2848
    @rodriguenjountsop2848 2 года назад +2

    Thank u very much!

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

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

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

    Very helpful

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

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

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

    Thanks a lot !!!!

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

    thank u very much bro

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

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

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

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

  • @Machiuka
    @Machiuka 2 года назад +2

    Thank a lot for this wonderful tutorial. :)

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

    Thank you so much ! Great Tutorial

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

    Thanks 🙏

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

    Thanks sir

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

    Excellent Tutorial

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

    Grate!

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

    Thanks for the Video !!

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

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

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

    Thank you so much.

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

    Thank you.

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

    Awesome 👍

  • @payelpaul8175
    @payelpaul8175 2 года назад +2

    thanks man

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

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

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

    It's very useful to me..thank you

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

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

  • @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 ?

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

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

  • @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.

  • @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))),}

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

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

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

    Thanks a lot

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

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

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

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

  • @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

  • @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.

  • @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

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

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

  • @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?

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

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

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

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

  • @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?

  • @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.

  • @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!

  • @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.

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

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

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

    how to display in scrollview the content

  • @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?

  • @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.

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

    How can I access Geo inside Address ?

  • @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?

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

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

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

    what about local file ??
    not https

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

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

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

    namosan damet garm khiliiiiiiii khobe site ke gfti

  • @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?

  • @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.

  • @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.

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

    how to show sub object json? :s

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

    why my load _user.length is null :(

  • @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

  • @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?

  • @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

  • @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?!

  • @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.

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

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

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

    data is not fetchable

  • @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