HTTPService class

HTTP Service - Core network implementation using dart:http

Centralized HTTP transport layer matching Swift/React Native HTTPService. Uses the http package as the HTTP client.

Features:

  • Environment-aware routing (Supabase for dev, Railway for prod)
  • Automatic header management
  • Proper timeout and error handling
  • Device registration with Supabase UPSERT support

Usage:

// Configure (called during SDK init)
HTTPService.shared.configure(HTTPServiceConfig(
  baseURL: 'https://api.runanywhere.ai',
  apiKey: 'your-api-key',
  environment: SDKEnvironment.production,
));

// Make requests
final response = await HTTPService.shared.post('/api/v1/devices/register', deviceData);

Properties

currentBaseURL String
Get current base URL
no setter
environment SDKEnvironment
Get current environment
no setter
hashCode int
The hash code for this object.
no setterinherited
isConfigured bool
Check if HTTP service is configured
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearToken() → void
Clear authorization token
configure(HTTPServiceConfig config) → void
Configure HTTP service with base URL and API key
configureDev(DevModeConfig config) → void
Configure development mode with Supabase credentials
delete<T>(String path, {T fromJson(Map<String, dynamic>)?, bool requiresAuth = false}) Future<T>
DELETE request
get<T>(String path, {T fromJson(Map<String, dynamic>)?, bool requiresAuth = false}) Future<T>
GET request
getRaw(String path, {bool requiresAuth = false}) Future<Uint8List>
GET request returning raw bytes
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
post<T>(String path, Object? data, {T fromJson(Map<String, dynamic>)?, bool requiresAuth = false}) Future<T>
POST request with JSON body
postRaw(String path, Uint8List payload, {bool requiresAuth = false}) Future<Uint8List>
POST request returning raw bytes
put<T>(String path, Object? data, {T fromJson(Map<String, dynamic>)?, bool requiresAuth = false}) Future<T>
PUT request
setToken(String token) → void
Set authorization token
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

shared HTTPService
Get shared HTTPService instance
no setter

Static Methods

resetForTesting() → void
Reset for testing