initialize method
Initialize the CDN config by loading the bundled JSON from package This should be called once during app initialization
Implementation
Future<void> initialize() async {
if (_isInitialized) return;
try {
// Load from package assets using package path
final jsonString = await rootBundle.loadString('packages/gokwik/lib/kp-config.json');
_bundledConfig = jsonDecode(jsonString) as Map<String, dynamic>;
_isInitialized = true;
} catch (error) {
// Fallback: try loading without package prefix (for development)
try {
final jsonString = await rootBundle.loadString('lib/kp-config.json');
_bundledConfig = jsonDecode(jsonString) as Map<String, dynamic>;
_isInitialized = true;
} catch (fallbackError) {
// ignore: avoid_print
print('Error loading bundled config: $fallbackError');
_bundledConfig = {};
_isInitialized = true;
}
}
}