Flutter - Accessing REST API Introduction | Part 4

Published: 30 September 2023
on channel: Online Solutions Academy
246
3

#REST API #flutter #apiintegration
Flutter provides http package to consume HTTP resources. http is a Future-based library and uses await and async features. It provides many high level methods and simplifies the development of REST based mobile applications.
Fetching data from the internet is necessary for most apps. Luckily, Dart and Flutter provide tools, such as the http package, for this type of work.
Basic Concepts
http package provides a high level class and http to do web requests.

http class provides functionality to perform all types of HTTP requests.

http methods accept a url, and additional information through Dart Map (post data, additional headers, etc.,). It requests the server and collects the response back in async/await pattern. For example, the below code reads the data from the specified url and print it in the console.

print(await http.read('https://flutter.dev/'));
Some of the core methods are as follows −

read − Request the specified url through GET method and return back the response as Future(String)

get − Request the specified url through GET method and return back the response as Future(Response). Response is a class holding the response information.

post − Request the specified url through POST method by posting the supplied data and return back the response as Future(Response)

put − Request the specified url through PUT method and return back the response as Future (Response)

head − Request the specified url through HEAD method and return back the response as Future(Response)

delete − Request the specified url through DELETE method and return back the response as Future(Response)


Watch video Flutter - Accessing REST API Introduction | Part 4 online without registration, duration hours minute second in high quality. This video was added by user Online Solutions Academy 30 September 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 246 once and liked it 3 people.