loadFlowConfigFromFile static method

Future<Map<String, dynamic>> loadFlowConfigFromFile(
  1. String enumType
)

Method to load flow configuration from file

Implementation

static Future<Map<String, dynamic>> loadFlowConfigFromFile(
  String enumType,
) async {
  __.in_('loadFlowConfigFromFile');
  try {
    // Check cache first
    if (_flowConfigCache.containsKey(enumType)) {
      return _flowConfigCache[enumType]!;
    }

    // Try to load from assets/json/{enumType}.json
    final String jsonPath = 'assets/json/$enumType.json';
    final String jsonString = await rootBundle.loadString(jsonPath);
    final Map<String, dynamic> config =
        json.decode(jsonString) as Map<String, dynamic>;

    // Cache the result
    _flowConfigCache[enumType] = config;
    __.info('Loaded flow config from file: $jsonPath');
    return config;
  } catch (e, stackTrace) {
    __.warning(
      'Failed to load configuration from file for $enumType: $e $stackTrace',
    );
    return {};
  } finally {
    __.out_('loadFlowConfigFromFile');
  }
}