nathanbaleeta/ureport_mobile

Create a Story class as a custom Dart object

Closed this issue · 0 comments

While retrieving stories from the U-Report public API stories endpoint, to make your life easier, convert the http.Response into a Dart object.

First, create a Story class in model directory that contains the API data from the network request. It includes a factory constructor that creates a Story from JSON. It includes the following data fields:


       {
		"id": Integer,
		"title": "String.",
		"featured": Bolean,
		"summary": "String",
		"video_id": Integer,
		"audio_link": String,
		"tags": " String ",
		"org": Integer,
		"images": ["String"],
		"category": {
			"image_url": "String",
			"name": "String"
		},
		"created_on": "datetime"
       }