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...

Комментарии • 21

  • @christianmichael7270
    @christianmichael7270 10 месяцев назад +2

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

  • @chiragdate6573
    @chiragdate6573 Год назад +1

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

  • @kxaif
    @kxaif 11 месяцев назад

    one of the best series 💌

  • @jeetgajjar516
    @jeetgajjar516 Год назад

    Wonderful work brother, your explanation is awesome brother

  • @TBDfilesLalit_kalyan
    @TBDfilesLalit_kalyan 9 месяцев назад

    absolutely awesome course..... absolutely awesome sir

  • @FlamingViCTiM
    @FlamingViCTiM 10 месяцев назад

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

  • @AshishGautam-sy3vm
    @AshishGautam-sy3vm 4 месяца назад

    great explanation

  • @christianmichael7270
    @christianmichael7270 10 месяцев назад +1

    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'],
    );
    }
    }"

  • @fa7tech
    @fa7tech Год назад

    Awsome explanation good job

  • @vedantmule6237
    @vedantmule6237 4 дня назад

    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.

  • @prem_chand.
    @prem_chand. Год назад +1

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

  • @vnikhil5844
    @vnikhil5844 2 года назад

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

  • @marco_di
    @marco_di Год назад

    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

    • @rolferikson
      @rolferikson Год назад

      Same problem, how did you solve it?

    • @NitishKumarSingh
      @NitishKumarSingh  Год назад +2

      Backend is returning null and you can’t cast it to Map

    • @marco_di
      @marco_di Год назад

      @@rolferikson I have wrapped the search option of the _onSearchChanged Widget in setState. Then Flutter clean, then Flutter pub get

  • @aciddeveloper9435
    @aciddeveloper9435 2 года назад

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

  • @omkarp9943
    @omkarp9943 Год назад

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

  • @someshsahu4638
    @someshsahu4638 Год назад +1

    Sir please explain how factory constructors work