Parsing JSON with PODO | Flutter

For those of you who do not know what is Flutter then

Flutter is an open-source mobile application development SDK created by Google. It is used to develop applications for Android and iOS.

or you can visit https://flutter.io

lets talk about JSON parsing in flutter

It is really confusing for beginners to understand how to parse JSON data.

Let’s Start with a example

Suppose I want to access the articles list but the articles has many attributes .

So How we are going to do that?

first of all we have to create a PODO (Plain Old Dart Object) for a particular article.

To access source in article we also have to create a PODO for source.

now make the network request

link= "https://newsapi.org/v2/top-headlines?country=in&apiKey=API_KEY";
var res = await http
.get(Uri.encodeFull(link), headers: {"Accept": "application/json"});

To get the list of articles

if (res.statusCode == 200) {
  var data = json.decode(res.body);
//access the articles as List
var rest = data["articles"] as List;
  list = rest.map<Article>((json) => Article.fromJson(json)).toList();
}

Complete method.

Complete code .

final app will look like this.

if I got something wrong? Let me in the comments. I would love to improve.

Clap If this this article helps you.

connect with me on LinkedIn .

Check my GitHub Repositories .

follow me on Twitter.

Thank you for reading this article.

Have a nice fluttery day!


The Flutter Pub is a medium publication to bring you the latest and amazing resources such as articles, videos, codes, podcasts etc. about this great technology to teach you how to build beautiful apps with it. You can find us on Facebook, Twitter, and Medium or learn more about us here. We’d love to connect! And if you are a writer interested in writing for us, then you can do so through these guidelines.