flutter
Send HTTP Get request in Flutter or Dart
In this post, we are listing some code examples that can be helpful in sending HTTP Get requests in Flutter or Dart. We use the http package of Dart to send requests.
import 'dart:convert';
import 'package:http/http.dart' as http;
void main {
final response = await http.get(Uri.parse("https://domain.com/endpoint?data=hello"));
String responseData = utf8.decode(response.bodyBytes);
print(json.decode(responseData));
}
We are using package:http/http.dart package to send HTTP get request. We are also using dart:convert package to convert our JSON response using json.decode(data) function.
If you are developing for the android platform, you need to add the user permission in AndroidManifest.xml file. The location of the manifest file is:
android/app/src/main/AndroidManifest.xml
The user permission code to be added to manifest file is:
<uses-permission android:name="android.permission.INTERNET"/>
Was this helpful?
Similar Posts
- Send HTTP POST request in Flutter or Dart
- Send a Map in query parameter of http request in Flutter
- Send Form Data in HTTP POST request in Flutter
- Get current timestamp in flutter or dart
- Convert a double to an int in Dart or Flutter
- String to double conversion in flutter [Dart]
- Find number of days between two dates in Flutter or Dart