05 Using factory constructor for json parsing | Flutter REST API Series

preview_player
Показать описание
Using factory constructor parsing the JSON and creating a model/object. This can make the code so much cleaner that it will blow your mind.

Рекомендации по теме
Комментарии
Автор

Thank you mate.. your course on rest api has been very well explained

christianmichael
Автор

One of the best Explaination of Rest API I've seen..Hats off!!!

chiragdate
Автор

Wonderful work brother, your explanation is awesome brother

jeetgajjar
Автор

thank you so much for your videos. they helped me so much

FlamingViCTiM
Автор

absolutely awesome absolutely awesome sir

TBDfilesLalit_kalyan
Автор

Nice Bro! Love Ur Work &
Also Pls make a video only on "Login page using php-MySql REST API with Xampp" 🥺🥺

prem_chand.
Автор

Sir please explain how factory constructors work

someshsahu
Автор

hey can you explain how to include mobx in the api created

vnikhil
Автор

Hello there. This is amazing tutorial and thank you for that. Can u make a video for other http like post put delete ?

aciddeveloper
Автор

Thanks for this really well explained tutorial... Unfortunately it doesn't work in my example. No matter what I try, I get unhandled exceptions... Unhandled Exception: type 'Null' is not a subtype of type 'Map<String, dynamic>'. Maybe it's the junction tables. I'm currently working with Strapi Headless CMS and the REST API with the ?populate filter option shows me all the data that Flutter doesn't seem to recognize

marco_di
Автор

Thanks brother!!
Send the link of this files/dir

omkarp
Автор

Thank you for this course is it really helpful. here is another way

"class UserLocation {
final String city;
final String state;
final String country;
final String postcode;
final LocationCoordinate coordinates;
final LocationStreet street;
final LocationTimezone timezone;

UserLocation(
{required this.city,
required this.state,
required this.country,
required this.postcode,
required this.coordinates,
required this.street,
required this.timezone});

factory UserLocation.fromMap(Map<String, dynamic> json) {
return UserLocation(
city: json['city'],
state: json['state'],
country: json['country'],
postcode: json['postcode'].toString(),
coordinates: LocationCoordinate.fromMap(json['coordinates']),
street: LocationStreet.fromMap(json['street']),
timezone: LocationTimezone.fromMap(json['timezone']),
);
}
}

class LocationCoordinate {
final String latitude;
final String longitude;

LocationCoordinate({
required this.latitude,
required this.longitude,
});
factory LocationCoordinate.fromMap(Map<String, dynamic> json) {
return LocationCoordinate(
latitude: json['latitude'],
longitude: json['longitude'],
);
}
}

class LocationStreet {
final int number;
final String name;

LocationStreet({
required this.number,
required this.name,
});
factory LocationStreet.fromMap(Map<String, dynamic> json) {
return LocationStreet(
number: json['number'],
name: json['name'],
);
}
}

class LocationTimezone {
final String offset;
final String description;

LocationTimezone({
required this.offset,
required this.description,
});

factory LocationTimezone.fromMap(Map<String, dynamic> json) {
return LocationTimezone(
offset: json['offset'],
description: json['description'],
);
}
}"

christianmichael