doh_api_client 1.0.0 doh_api_client: ^1.0.0 copied to clipboard
A Simple API Client that implemented DoH (DNS over HTTPS) protocol using Native Method Channels.
DoH API Client Flutter Package #
A Flutter package that provides an API client using the DNS over HTTPS (DoH) protocol, implemented with Kotlin Native code for optimal performance.
Features #
- Perform HTTP requests (GET, POST, PUT, PATCH, DELETE) using DoH protocol
- Support for 12 different DoH providers
- Easy integration with Flutter projects
- Kotlin Native implementation for improved performance (Also because it is only possible through native code)
Installation #
Add this to your package's pubspec.yaml
file:
dependencies:
doh_api_client: ^1.0.0
Then run:
flutter pub get
Usage #
First, import the package in your Dart file:
import 'package:doh_api_client/doh_api_client.dart';
Making API Requests #
Here's an example of how to make a POST request using the DoH API client:
final _dohApiClientPlugin = DohApiClient();
try {
String apiPostRequest = await _dohApiClientPlugin.post(
url: "https://jsonplaceholder.typicode.com/posts",
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
'Content-type': 'application/json; charset=UTF-8'
},
body: jsonEncode({
"title": 'foo',
"body": 'bar',
"userId": 1,
}),
dohProvider: DohProvider.CloudFlare
);
print(apiPostRequest);
} catch (e) {
print("Error occurred: $e");
}
Available DoH Providers #
The package supports the following DoH providers:
- CloudFlare
- AdGuard
- Quad9
- AliDNS
- DNSPod
- threeSixty
- Quad101
- Mullvad
- ControlD
- Najalla
- SheCan
You can specify the DoH provider using the DohProvider
enum when making requests.
API Reference #
DohApiClient #
The main class for making API requests.
Methods:
Future<String?> get({required String url, Map<String, String>? headers, DohProvider dohProvider})
Future<String?> post({required String url, Map<String, String>? headers, required String body, DohProvider dohProvider})
Future<String?> put({required String url, Map<String, String>? headers, required String body, DohProvider dohProvider})
Future<String?> patch({required String url, Map<String, String>? headers, required String body, DohProvider dohProvider})
Future<String?> delete({required String url, Map<String, String>? headers, DohProvider dohProvider})
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
This project is licensed under the MIT License - see the LICENSE file for details.