customfit_ai_flutter_core library

CustomFit.ai Flutter SDK Core Components

This library provides the core functionality for the CustomFit.ai Flutter SDK, including feature flag evaluation, analytics tracking, user management, and real-time configuration updates.

Main Components

  • CFClient: Main SDK client for feature flags and analytics
  • CFConfig: Configuration settings for SDK initialization
  • CFUser: User context and properties for targeting
  • CFResult: Result wrapper for error handling

Usage

import 'package:customfit_ai_flutter_sdk/customfit_ai_flutter_core.dart';

// Initialize the SDK
final config = CFConfig.development('your-api-key');
final user = CFUser.builder('user-id').build();
final client = await CFClient.initialize(config, user);

// Evaluate feature flags
final isEnabled = client.featureFlags.getBoolean('feature-key', false);

// Track events
await client.trackEvent('user-action');

Classes

AdaptiveConfig
Adaptive configuration based on network conditions
AllFlagsListener
Listener interface for receiving all feature flag changes.
ApplicationInfo
Collects and stores information about the application for use in targeting and analytics
BandwidthMeasurement
Individual bandwidth measurement
BandwidthMonitor
Bandwidth monitoring and adaptive optimization
BooleanEventProperty
Boolean event property
BooleanFeatureFlagValue
Boolean feature flag value
BooleanFlag
Type-safe boolean feature flag
Builder
Builder class for CFConfig
CacheEntry<T>
CacheEntry represents a cached value with metadata
CacheManager
CacheManager provides persistent caching for configurations with TTL
CachePolicy
Cache policy to control caching behavior
CFClient
Main SDK client for CustomFit feature flags, analytics, and configuration management.
CFClientEvents
Handles all event tracking operations for CFClient
CFClientFeatureFlags
Feature flag evaluation component for CFClient
CFClientListeners
Component responsible for managing all types of listeners in the CFClient. Handles feature flag listeners, configuration change listeners, and event subscriptions.
CFClientRecovery
Recovery component that handles system health checks and recovery operations
CFConfig
Immutable configuration class for CustomFit SDK initialization.
CFConfigAnalyzer
Configuration comparison and analysis utilities
CFConstants
Constants used throughout the SDK.
CFError
Error details for failed operations
CFErrorCode
Standardized error codes for CustomFit SDK Error codes follow a 4-digit format: XYYY
CFFlagProvider
Flag provider that uses the mediator pattern to avoid circular dependencies This eliminates the direct dependency on CFClient, solving the circular dependency issue
CFResult<T>
Mirrors Kotlin's sealed CFResult with generic type T.
CFUser
User model defining identity, properties, and targeting context for the CustomFit SDK.
CFUserBuilder
Builder for creating CFUser instances with a fluent API
CircuitBreakerEvent
Circuit breaker state change record
ConfigManager
Interface for ConfigManager
ConfigManagerImpl
Implementation of ConfigManager
ConnectionInformation
Detailed info about the SDK’s connection state
ConnectionPool
Connection pool for efficient HTTP/2 multiplexing
ConnectionStatusListener
Callback for connection status changes
DependencyContainer
Improved dependency injection container Provides improved dependency injection with better patterns
DependencyFactory
Abstract factory interface for creating SDK dependencies Used for dependency injection in tests
DeviceContext
Represents device and operating system information for context-aware evaluation
EnumFlag<T extends Enum>
Type-safe enum feature flag
EnvironmentManager
Interface for EnvironmentManager
EnvironmentManagerImpl
Implementation of EnvironmentManager
ErrorCategory
Describes the category of an error for better debugging and handling This is modeled after the Kotlin ErrorCategory enum
EventData
Represents event data to be sent to the backend
EventProperties
Convenience factory for creating typed event properties
EventPropertiesBuilder
Matches Kotlin's empty subclass of PropertiesBuilder This class is maintained for backward compatibility
EventPropertyValue
Common event property types with validation
EventRecoveryResult
Result of event recovery operations
EventTracker
Implements robust event tracking with batching, retry logic, and network awareness.
FeatureFlagChangeListener
Listener for feature flag changes.
FeatureFlags
Type-safe feature flag definitions
FeatureFlagValue
Sealed class representing different types of feature flag values
FlagDefinition<T>
Base class for type-safe feature flag definitions
FlagProvider
Interface for providing feature flag values
JsonFeatureFlagValue
JSON feature flag value
JsonFlag<T>
Type-safe JSON feature flag
JsonParser
Optimized JSON parser with caching and performance improvements
ListenerManager
Manager for handling various types of listeners in the SDK
Logger
SDK logging utility class that provides enhanced logging capabilities
LogLevelUpdater
Helper class to update log levels based on configuration
MemoryManager
Memory management utility for the CustomFit SDK
MutableCFConfig
Mutable configuration wrapper for runtime updates
NetworkHealthMetrics
Network health metrics data structure
NetworkHealthMonitor
Comprehensive network health monitoring system
NetworkOptimizer
Main network optimization coordinator
NumberEventProperty
Number event property
NumberFeatureFlagValue
Number feature flag value
NumberFlag
Type-safe number feature flag
PayloadOptimizer
Payload optimization for size reduction
PipelinedRequest
Individual pipelined request
PooledConnection
Individual pooled connection with stream management
RemoteLogger
Remote logger implementation for Flutter
RequestPipeline
Request pipelining manager for batching requests
RequestRecord
Individual request record for tracking
RetryAttemptInfo
Information about retry attempts
RetryUtil
Improved retry utility with CFResult error handling
SessionConfig
Configuration for session management
SessionData
Represents a session with metadata
SessionManager
Manages session IDs with time-based rotation strategy
SessionRotationListener
Session rotation listener interface
StringBuilder
Builder class for complex string operations
StringEventProperty
String event property
StringFeatureFlagValue
String feature flag value
StringFlag
Type-safe string feature flag
StringOptimizer
String optimization utilities for better performance
SystemHealthStatus
Comprehensive system health status
TypedEventProperties
Base class for typed event properties
TypedEventPropertiesBuilder
Builder for typed event properties
TypedEventPropertiesImpl
Implementation of typed event properties
UserManager
Interface for UserManager
UserManagerImpl
Implementation of UserManager
WeakCache<T extends Object>
Weak cache implementation for temporary storage

Enums

CFEnvironment
Environment types for API endpoints
CircuitBreakerState
Circuit breaker states for resilience patterns (standardized across all platforms)
ConnectionStatus
SDK connection states (standardized across all platforms)
ContentType
Content types for HTTP requests (standardized across all platforms)
ErrorSeverity
An enum representing the severity of an error.
EventType
Represents the type of events that can be tracked
HttpMethod
HTTP methods for network requests (standardized across all platforms)
LogLevel
Log levels for the SDK (standardized across all platforms)
LogProvider
Log providers supported by the remote logger
NetworkQuality
Network quality levels
NetworkType
Network types for device connectivity (standardized across all platforms)
RemoteLogLevel
Remote log levels
RotationReason
Reasons for session rotation
SystemOverallStatus
Overall system health status

Extensions

ConnectionStatusExtension on ConnectionStatus
Extension methods for ConnectionStatus
ErrorSeverityExtension on ErrorSeverity
Extension methods for ErrorSeverity.
EventTypeExtension on EventType
Extension methods for EventType
GetIt on DependencyContainer
StringOptimizerExtensions on String
Extension methods for String class to add optimization shortcuts

Functions

synchronized<T>(Object lock, T fn()) → T
Helper for synchronized blocks

Typedefs

EventCallback = void Function(EventData event)
Callback for event tracking notifications

Exceptions / Errors

CFException
Exception wrapper for CFError