Complete the code to import the package needed for HTTP requests in Flutter.
import [1];
The http package is used to make GET and POST requests in Flutter.
Complete the code to send a GET request to the given URL.
final response = await http.[1](Uri.parse('https://example.com/data'));
Uri.parse().The get method sends a GET request to fetch data from the server.
Fix the error in the POST request code by completing the missing method.
final response = await http.[1](Uri.parse('https://example.com/post'), body: {'key': 'value'});
The post method is used to send data to the server.
Fill both blanks to check if the GET request was successful and print the response body.
if (response.statusCode [1] 200) { print(response.[2]); }
We check if the status code equals 200, which means success, then print the response body.
Fill all three blanks to send a POST request with JSON headers and body.
final response = await http.[1]( Uri.parse('https://example.com/api'), headers: {'Content-Type': '[2]'}, body: [3], );
Use post to send data, set header to application/json, and encode the body as JSON.
