loadFromStorage method

Future<void> loadFromStorage()

Load configuration from storage

Implementation

Future<void> loadFromStorage() async {
  try {
    _currentApiKey = await _storage.read(key: 'onairos_api_key');
    _environment = await _storage.read(key: 'onairos_environment') ?? 'production';

    // If no key found, auto-initialize with admin key
    if (_currentApiKey == null) {
      await initialize(autoInitWithAdmin: true);
    } else {
      _isInitialized = true;
    }

  } catch (e) {
    OnairosDebugHelper.log('❌ Error loading API key from storage: $e');
    // Auto-initialize with admin key if loading fails
    await initialize(autoInitWithAdmin: true);
  }
}