Fetching Data from API | Part - 2 | HTTP get Request in Flutter | Hindi

Sdílet
Vložit
  • čas přidán 29. 08. 2024
  • To fetch data from an API in a Flutter app, you can use the http package, which provides a simple and efficient way to make HTTP requests and receive HTTP responses.
    Here is an example of how you might use the http package to fetch data from an API in a Flutter app:
    import 'package:http/http.dart' as http;
    // Make a GET request to the API
    final response = await http.get('example.com/ap...
    // Check the status code of the response
    if (response.statusCode == 200) {
    // If the request was successful, parse the JSON data
    final data = json.decode(response.body);
    // Use the data as needed
    } else {
    // If the request was unsuccessful, throw an error
    throw Exception('Failed to fetch data');
    }
    In this example, the http.get function is used to make a GET request to the API, and the response object is used to hold the response from the server. The statusCode property of the response object is used to check whether the request was successful or not, and the body property is used to hold the data returned by the server.
    You can also use the http package to make other types of HTTP requests, such as POST, PUT, and DELETE, by using the http.post, http.put, and http.delete functions, respectively.
    Blog: www.ahirlog.co...
    My CZcams Gear:
    Boya BYM1(Mic): amzn.to/3bvm69j
    Redmi Note 7 Pro(Mic & Camera): amzn.to/3uRkVsb
    MSI Motherboard: amzn.to/3fiQHYO
    Intel i3 Processor: amzn.to/3w8TWbQ
    Mouse: amzn.to/3yb8PMP
    Keyboard: amzn.to/3bvmtkd
    Wifi Adaptor: amzn.to/3fiQYuO
    SSD: amzn.to/3w2w2Pa
    Speakers: amzn.to/3w6pKhv
    Instagram: / ahirlog
    Facebook: / ahirlog
    Twitter: / ahirlog
    CZcams: / ahirlog
    #ahirlog #flutter #dart
    Last Summer by Ikson: / ikson​
    Music promoted by Audio Library • Last Summer - Ikson (N...

Komentáře • 57

  • @avilashbhowmik3995
    @avilashbhowmik3995 Před 8 měsíci +1

    The way of your explaination, was really great as usual. Thanks a lot brother.

  • @aakashgaming8659
    @aakashgaming8659 Před rokem +2

    great video bro i got errors in my code but after watching this video .I have solve errors in my code thanks you bro .

  • @vinit_972
    @vinit_972 Před rokem +3

    My friend Axit kapadiya is only depended on your you tube channel

  • @Anillucky25
    @Anillucky25 Před 6 měsíci

    hello bhai,
    thanks for this video the way of explaining is very easy to understanding and good and expecting more API's like post, put patch method. it's really appreciate thanks.

  • @hemanshpandya765
    @hemanshpandya765 Před rokem +3

    brother very good for beginners

  • @hassamkayani2521
    @hassamkayani2521 Před rokem +2

    Plz make a view of API Post Method ....Boht acha samjty ho bhai ap ...Love from Pakistan

    • @ahirlog
      @ahirlog  Před rokem

      Thank you

    • @hassamkayani2521
      @hassamkayani2521 Před rokem

      @@ahirlog plz Brother Api k Post b karwa do..plz

    • @hassamkayani2521
      @hassamkayani2521 Před rokem

      @@ahirlog agr ap ny already video upload ki hoi hye to Mujy link day do ma dakh leta hu

    • @ahirlog
      @ahirlog  Před rokem

      I will make

  • @Second_zoneHandler
    @Second_zoneHandler Před 10 měsíci +1

    yeh same apan Provider se bhi kar sakte hai instead of listviewbuilder
    right?

  • @FunGamerz-786
    @FunGamerz-786 Před rokem +1

    thank you very much ahirlog this video

  • @ak4me
    @ak4me Před rokem +4

    exact the same code but circle is rotation all the time

  • @someshsahu4638
    @someshsahu4638 Před rokem +2

    Nice video thankyou 🙏🏼

  • @user-eh4fm7uq6w
    @user-eh4fm7uq6w Před měsícem

    Please bring State Management course

  • @shivamnexvlogs7986
    @shivamnexvlogs7986 Před rokem +3

    please make a video on post and put and delete method of http for api

  • @shortcasthub091
    @shortcasthub091 Před rokem +3

    hey bro i found this error while fetching data, will you please help me to fix this error
    _TypeError (type '_InternalLinkedHashMap' is not a subtype of type 'Iterable')

    • @ahirlog
      @ahirlog  Před rokem

      Use type cast as List or use .toList

    • @alaaabdullah2648
      @alaaabdullah2648 Před rokem +1

      @@ahirlog can you please explain where should I add .toList

  • @hisamsikder9555
    @hisamsikder9555 Před rokem +1

    how to add webview inside a button .
    when i click that button it open webview

  • @Beavers-v9y
    @Beavers-v9y Před 7 měsíci

    Thanku bhai

  • @ankitnagar9184
    @ankitnagar9184 Před rokem +1

    Type error string dynamic is not a sub type of type itrable bro pls solve

    • @ahirlog
      @ahirlog  Před rokem

      Use .tolist or type cast

  • @mekaamrutha7213
    @mekaamrutha7213 Před 7 měsíci

    Iam getting errors In home_page.dart,how can i modifying

  • @BasantKumar-bg3fg
    @BasantKumar-bg3fg Před rokem

    here you are showing data from jsonarray, please can you help me to get jsonobject from api by button click and show in text widget ?

  • @moizahmed5372
    @moizahmed5372 Před rokem +1

    ty

  • @Wardatu4
    @Wardatu4 Před 8 měsíci

    It's http or api

  • @PriyaSingh-do3qg
    @PriyaSingh-do3qg Před rokem +1

    Post api ki video bana dijiye

  • @ctvtechno4992
    @ctvtechno4992 Před rokem +1

    how to upload images

  • @shekhawat999mohit
    @shekhawat999mohit Před 3 měsíci

    bhai aawaj kam h thodi

  • @kainatnaeem2604
    @kainatnaeem2604 Před rokem +1

    I want to fetch questions an answers from stackoverflow could you please guide

    • @ahirlog
      @ahirlog  Před rokem

      I am not sure about stack overflow, but I think if they provide api for then you use that api and fetch the data

  • @snehdeepukey1279
    @snehdeepukey1279 Před rokem +1

    SIr aapka contact detail share karo na

  • @HelloWorld-tx4qn
    @HelloWorld-tx4qn Před rokem +1

    i need some help

  • @dushyantsharma2415
    @dushyantsharma2415 Před rokem +1

    how to fetch nested api its difficult bro please reply

  • @vickramkumar9005
    @vickramkumar9005 Před rokem +2

    bhai awaaz badhao sunai he nahi deti aap ki awaaz

  • @OwaisKhan-dm8vb
    @OwaisKhan-dm8vb Před rokem +1

    Vdo quality is poor

  • @parvejchhipa4253
    @parvejchhipa4253 Před rokem +1

    http pakage ki jagh dio use karna kesa haiiiii....

  • @13soulmate13
    @13soulmate13 Před rokem +2

    Type error string dynamic is not a sub type of type itrable bro pls solve

    • @ahirlog
      @ahirlog  Před rokem

      I will make video on this