Flutter - Convert Complex JSON to Dart Classes Easily | JSON Serialization

preview_player
Показать описание
#flutter #json #serialization

In this Flutter Tutorial, we will be talking a look at using Json Serializable, Build Runner & Flutter Annotation package to auto generate code to easily convert Json Data to Dart Classes. This is a good approach for complex applications where classes and dart object can have too many properties to handle code manually.

🔥 Auto-Generate Flutter Custom Paint Code TRY THIS FREE TOOL👇:

🔥 Learn About the Most Important Widgets in Flutter 👇:

(Your UPVOTE Means a lot! 🙌)

If you find this video useful consider Supporting @RetroPortal Studio :

Social Links @RetroPortal Studio :

If you like the tutorial, please hit the LIKE and Subscribe button and also consider supporting me on Patreon or Buy Me a Coffee for More Flutter Tutorial on RetroPortal Studio.

Thank you for Watching! Happy Coding :)
Рекомендации по теме
Комментарии
Автор

Great video! As for VsCode users, Dart Data Class Generator Extension is a great choice, as you don't need any dependencies, just right click the class and press generate json data

storylineteam
Автор

This saved me after 3 sleepless nights, so thanks! The package docs hasn't really made some of those parts clear, in contrast to yours that's concise and very clear to understand.

mrvfino
Автор

If you find this video useful, consider Following me on:
Happy Coding! ✌️😁

RetroPortalStudio
Автор

I love you man, you just saved me a headache

megrel
Автор

Very helpful and appreciated. Consider adding _ demo _ actually running the code with mock data.

BillBrutzman
Автор

Great solution, I can't thank you enough. Be safe and keep up the good work.

SHAFIulBARI
Автор

That was a great explanation, It really cleared my all doubts and thanks for creating this awesome video, I read Flutter Complete Reference Book before watching this video, Keep going Bro

abhishekbhambure
Автор

Clear explanation. Awsome work. Thanks a lot.

maha
Автор

You just save my day. I wanna learn more .. thank you

aldyanimayazar
Автор

Thanks it's nice and easy explain. i have one question user upload image file is converted in to Json and get back to user in image this way?

prakashanuvadia
Автор

Great solution. Will be trying this on the next project.

ArpitA
Автор

explicitToJson: true --> 2h to find the solucion, THANK YOU

plugarutudor-stefan
Автор

Thanks,
Do this with more briefly too.

hassanosama
Автор

I don't like all the boilerplate code for those packages either, but it's a bit better at least.
I wonder why Dart needs the boilerplate, I've never had to do that in any other language.

WorstDeveloper
Автор

Can you please explain why its necessary to convert the json to a class before using it? Im not an advanced flutter user but in my apps I just use the json as it is after receiving it and then map what I need to my list views

thefamousdjx
Автор

But I have one doubt how will we test the file or how to write a test case ?

praneethchinna
Автор

My class has TImestamp field so .g.dart file is not generating. How can I solve this problem?

MahbuburRahman-ucnp
Автор

Great Tutorial 👍🤩 ... is it also usable with Strapi v4 & GraphQL? The JSON's there are looking like very complex JSON's. ClassUser { Data { id, attributes { firstName, lastName, age ... it seems like user information is in a subclass "attributes", a subclass of the user "id"

marco_di
Автор

I imagine this serialization will become built in to Dart core sooner or later. I use DotNetCore api and I can throw regular c# objects as IActionResult tasks and dotNetCore makes it a json, xml or whatever the httpRequest wants. In Dart/Flutter though, we gotta do this Json serialization setup for every single object. ( I mean this isn't done in javascript - well because it is java script objects - the json - but, Why should dart/Flutter devs have to always do this hand-coding serializtion? If it weren't for json-serializor library mentioned here, I would've quit Flutter before I even began using it.

Gabeyre
Автор

Nice video, but what happens when a model extends another model? Like User could extends Person, would the serialization work in same way?

leosconflicts
visit shbcf.ru