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

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

ความคิดเห็น • 39

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

  • @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

    • @duasepuluh3419
      @duasepuluh3419 2 ปีที่แล้ว

      i feel you bro.. me too :D
      subs + 1

  • @proboy1739
    @proboy1739 2 ปีที่แล้ว

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

  • @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

  • @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

  • @uzzmasaiyed
    @uzzmasaiyed 8 หลายเดือนก่อน

    Great video, you solved my problem thanxalot

  • @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!

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

  • @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. :)

  • @lalremlianbtlung9042
    @lalremlianbtlung9042 2 ปีที่แล้ว

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

  • @crazyworld3662
    @crazyworld3662 2 ปีที่แล้ว

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

  • @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

  • @pritimaurya7255
    @pritimaurya7255 3 ปีที่แล้ว

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

  • @tanaysingh1668
    @tanaysingh1668 3 ปีที่แล้ว

    how "id" is created automatically ??

  • @nested9301
    @nested9301 3 ปีที่แล้ว

    why you did not encode the body?

  • @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

  • @yassinabdulla368
    @yassinabdulla368 2 ปีที่แล้ว

    thanks it helped alot

  • @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.
      th-cam.com/video/LGNKzfBmNmk/w-d-xo.html

    • @TheMrGreenMoney
      @TheMrGreenMoney 3 ปีที่แล้ว

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

  • @mohamedwaleed4610
    @mohamedwaleed4610 ปีที่แล้ว

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

  • @shohzodzet
    @shohzodzet 3 ปีที่แล้ว

    Thank you!

  • @cruisetom5838
    @cruisetom5838 2 ปีที่แล้ว

    where is source ?
    source githun url ????

  • @TheMypencil
    @TheMypencil 3 ปีที่แล้ว

    Thank you​

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

  • @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