05 Using factory constructor for json parsing | Flutter REST API Series
HTML-код
- Опубликовано: 4 окт 2024
- 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.
Facebook: / nitishk72
LinkedIn: / nitishk72
Patreon: / nitishk72
Github: github.com/nit...
Thank you mate.. your course on rest api has been very well explained
One of the best Explaination of Rest API I've seen..Hats off!!!
one of the best series 💌
Wonderful work brother, your explanation is awesome brother
absolutely awesome course..... absolutely awesome sir
Many thanks
thank you so much for your videos. they helped me so much
great explanation
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 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 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 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 json) {
return LocationTimezone(
offset: json['offset'],
description: json['description'],
);
}
}"
Awsome explanation good job
Hello sir,
You told all the things very well.
But one thing I got annoyed of us you didn't share the direct code github link.
You just shared your profile link. I am getting an error and can't able to verify the code after I wrote.
Please see to it, and take action accordingly.
Nice Bro! Love Ur Work &
Also Pls make a video only on "Login page using php-MySql REST API with Xampp" 🥺🥺
hey can you explain how to include mobx in the api created
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'. 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
Same problem, how did you solve it?
Backend is returning null and you can’t cast it to Map
@@rolferikson I have wrapped the search option of the _onSearchChanged Widget in setState. Then Flutter clean, then Flutter pub get
Hello there. This is amazing tutorial and thank you for that. Can u make a video for other http like post put delete ?
ruclips.net/video/Wsor0fci3Ss/видео.html
Thanks brother!!
Send the link of this files/dir
Sir please explain how factory constructors work