createNetworkConfig function
Create network configuration from SDK init options
Matches React Native createNetworkConfig function.
Implementation
NetworkConfig createNetworkConfig({
required String apiKey,
String? baseURL,
String? environmentStr,
SDKEnvironment? environment,
String? supabaseURL,
String? supabaseKey,
int? timeoutMs,
}) {
// Map string environment to enum if provided
SDKEnvironment env = environment ?? SDKEnvironment.production;
if (environmentStr != null) {
switch (environmentStr.toLowerCase()) {
case 'development':
env = SDKEnvironment.development;
break;
case 'staging':
env = SDKEnvironment.staging;
break;
case 'production':
env = SDKEnvironment.production;
break;
}
}
// Build supabase config if provided
final supabase = supabaseURL != null && supabaseKey != null
? SupabaseNetworkConfig(
url: supabaseURL,
anonKey: supabaseKey,
)
: null;
return NetworkConfig(
baseURL: baseURL ?? NetworkConfig.defaultBaseURL,
apiKey: apiKey,
environment: env,
supabase: supabase,
timeoutMs: timeoutMs ?? NetworkConfig.defaultTimeoutMs,
);
}