http_platforms 1.0.4
http_platforms: ^1.0.4 copied to clipboard
A versatile HTTP networking package for Dart/Flutter that supports Web, Android, and iOS. Simplify API requests with cross-platform compatibility.
example/http_platforms_example.dart
import 'dart:convert';
import 'package:http_platforms/http_platforms.dart';
void main() async {
var url =
Uri.https('www.googleapis.com', '/books/v1/volumes', {'q': '{http}'});
// Await the http get response, then decode the json-formatted response.
var response = await HttpPlatform.get(url: url.origin);
if (response.statusCode == 200) {
var jsonResponse = jsonDecode(response.body) as Map<String, dynamic>;
var itemCount = jsonResponse['totalItems'];
print('Number of books about http: $itemCount.');
} else {
print('Request failed with status: ${response.statusCode}.');
}
}