1.5 KiB
1.5 KiB
TrustAPP_httpdns_example
Demonstrates how to use the TrustAPP_httpdns plugin with various network libraries.
Features
This example demonstrates:
- HTTPDNS initialization and configuration
- Domain name resolution (IPv4 and IPv6)
- Integration with multiple network libraries:
- Dio
- HttpClient
- http package
- Custom HTTP client adapter for HTTPDNS
- Real HTTP requests using HTTPDNS resolution
Getting Started
-
Replace the SDK init parameters in
lib/main.dartwith your own values:await TrustAPPHttpdns.init( appId: 'YOUR_APP_ID', primaryServiceHost: 'httpdns-a.example.com', backupServiceHost: 'httpdns-b.example.com', servicePort: 443, secretKey: 'YOUR_SIGN_SECRET', // optional if sign is enabled ); -
Install dependencies:
flutter pub get -
Run the app:
flutter run -
Try the features:
- Enter a URL and select a network library (Dio/HttpClient/http)
- Tap "Send Request" to make an HTTP request using HTTPDNS
- Tap "HTTPDNS Resolve" to test domain resolution directly
Implementation Details
The example uses a modern approach with HttpClient.connectionFactory to integrate HTTPDNS:
- See
lib/net/httpdns_http_client_adapter.dartfor the implementation - This approach avoids the complexity of local proxy servers
- Works seamlessly with Dio, HttpClient, and http package
Note
The values in this example are placeholders. Use your own platform app configuration.