Http Post Method - Flutter || Post Data to API in flutter

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024
  • In this video we will see how to use http post method in flutter.
    Kindly go through the full video to get all the details of how this method works.
    #flutter #Http # httpFlutter #flutterpost
  • НаукаНаука

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

  • @azizlachkar8494
    @azizlachkar8494 2 года назад +1

    you are literally the first ever video that worked from the first try without any bugs or error i have no idea what to say except thank you very much sir

  • @EyupJohn
    @EyupJohn 2 года назад +3

    Video is useful but needs some changes like: you need to add json.encode() to body.
    For example:
    body: json.encode({
    "test": "test"})
    and add headers after the body, like:
    headers: { 'Content-type': 'application/json',
    'Accept': 'application/json'})
    if you're having
    "The body might complete normally, causing 'null' to be returned, but the return type, 'FutureOr', is a potentially non-nullable type."
    error message, then you can change future type to Future and use it like a function returning bool value (after checking it's statusCode ofc.) And also don't forget to add "await" before calling the function.
    Anyways, thanks for the video.

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

      By the time you saw my message, this solution way may also been out dated.

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

      Hi, I'm having the same issue.

  • @relebohilenkaki8355
    @relebohilenkaki8355 2 года назад +2

    The body might complete normally, causing 'null' to be returned, but the return type, 'FutureOr', is a potentially non-nullable type.
    I am getting this error in future function method. Please Help

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

    It is really a helpful lecture for understanding Please tell me the shortcut to wrap a widget inside a widget

  • @uzzmasaiyed
    @uzzmasaiyed 8 месяцев назад

    Great video, you solved my problem thanxalot

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

    Flutter task:
    First Screen - Prepare a list using a api call
    Second Screen - create another screen where u can fill the details related to list and write validations for fields.
    And filled details should add to the first screen listings

  • @pakistanihub5445
    @pakistanihub5445 3 года назад

    When i create ModelClass.dart and then try to import it in main.dart file then it gives error as it does'nt import it to main class. And when we use it in inside the arguments of Future then it also does'nt accept it and give different errors on run time. So kindly tell me a solution of how to solve it.

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

    Thank you so much. It worked and you explained it very well. :)

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

    Sir you are picking something from there 10:06 what is this. Is it same for all. I am just confused with the thing you are working with outside of flutter!

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

    after i put data how to show this data in next screen with name,job,id,create at please replay me.

  • @pritimaurya7255
    @pritimaurya7255 3 года назад

    What if I post blank . I mean null values in name and Job will it work?

  • @ryancitocoreano
    @ryancitocoreano 3 года назад +1

    Hi, I am new to dart and flutter, so I appreciate to you for this lecture.
    I followed along your lecture it's exceptionally nice.
    I've got two questions while following your lecture.
    #1
    at 13:34, you completed without returning for function submitData,
    and there is underline for this. It's perfectly working without return dataModelFromJson(responseString);
    and also it looks working with return dataModelFromJson(responseString);
    by the looks of print(data)
    Is there any reason you didn't add return for this?
    #2
    at 13:45, you initialized DataModel _dataModel;
    I found out that _dataModel has underline and vs code shows that
    M - 'The value of the field '_dataModel' isn't used. Try removing the field, or using it.
    I was thinking like "okay, then I am gonna remove DataModel _dataModel; because it's not used", but if I remove DataModel _dataModel; , I got an error because I removed it that used to update value in setState!
    so, I am confused with it.

  • @tlhohonolofatsogeorgemotlo5950
    @tlhohonolofatsogeorgemotlo5950 3 года назад +1

    it worked well my friend, thank you very much

    • @flutterwithme2530
      @flutterwithme2530  3 года назад +1

      You're welcome!

    • @tlhohonolofatsogeorgemotlo5950
      @tlhohonolofatsogeorgemotlo5950 3 года назад

      @@flutterwithme2530 pleasure.. i have another problem, for my project i was using the login api where i submit my email and password. the response body shows the user details(profile) which is a good thing but now i want to access the name and surname of the user from the JSON response body, so how do i do that??? please help

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

    How do I populate data to the model after retrieving a data from an API?

  • @shreyasgaurb
    @shreyasgaurb 3 года назад

    Hi, what can I do if I have loads of form fields and a very huge JSON data? My request body will be flooded, for now I have given only 3 fields in the body like you, but my model has more than 50 fields and I need to post them all, one way to do this is by passing the entire json data in the body but i don't know how to do that exactly cause the code would look very bad with such huge amount of data in the body. Please help me!

    • @flutterwithme2530
      @flutterwithme2530  3 года назад

      You would need to pass the entire data if you need it all, there is no workaround to that.
      Happy Coding!!

  • @rajeshsanuria5656
    @rajeshsanuria5656 3 года назад

    please make a video on put request

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

    how to print the results in an alert instead of console ? please anyone tell me how to do this🤚

  • @randaalojairy9785
    @randaalojairy9785 3 года назад +1

    Plese can you make video for how to make login system using http post and the database is Postgres sql in flutter!

    • @flutterwithme2530
      @flutterwithme2530  3 года назад

      Already have a video for that.
      ruclips.net/video/LGNKzfBmNmk/видео.html

    • @TheMrGreenMoney
      @TheMrGreenMoney 3 года назад

      @@flutterwithme2530 How could I do this with an api? I'm using django rest framework.

  • @tanaysingh1668
    @tanaysingh1668 3 года назад

    how "id" is created automatically ??

  • @nested9301
    @nested9301 3 года назад

    why you did not encode the body?

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

    thanks it helped alot

  • @bassapabubanale1442
    @bassapabubanale1442 3 года назад

    How to show this data on anothe page as list flutter

    • @flutterwithme2530
      @flutterwithme2530  3 года назад

      pass it on to other pages using provider or setstate.

  • @technologyandknowledge8465
    @technologyandknowledge8465 3 года назад

    how to use it in localserver. Useing php and mysql

    • @flutterwithme2530
      @flutterwithme2530  3 года назад

      You will need to create API's using node or any other platform.

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

    where is source ?
    source githun url ????

  • @shohzodzet
    @shohzodzet 3 года назад

    Thank you!

  • @TheMypencil
    @TheMypencil 3 года назад

    Thank you​

  • @Hadir_kad
    @Hadir_kad 3 года назад

    💜💜💜💜💜💜💜💜

  • @amirhosseinrajaizadeh2232
    @amirhosseinrajaizadeh2232 3 года назад

    WHERE IS THE SOURCE CODE??? WORTH TUTORIAL

  • @pagadalamahidharsri6344
    @pagadalamahidharsri6344 2 года назад +1

    Flutter task:
    First Screen - Prepare a list using a api call
    Second Screen - create another screen where u can fill the details related to list and write validations for fields.
    And filled details should add to the first screen listings