handleGetAllVariants method

Future<Map<String, Map<String, dynamic>>> handleGetAllVariants()

Returns all loaded feature flag variants in the camelCase wire shape that the iOS/Android handlers produce (so the Dart wrapper stays platform-agnostic).

Reads the internal mixpanel.flags.flags Map directly. The map yields variants with snake_case keys (key / value / experiment_id / is_experiment_active / is_qa_tester), which _convertJsFlagsMap translates to the camelCase shape the Dart wrapper expects.

Implementation

Future<Map<String, Map<String, dynamic>>> handleGetAllVariants() async {
  try {
    final raw = flags_internal_map;
    // mixpanel.flags.flags is a JS Map; dartify() treats JS Map/Set as opaque,
    // so flatten to a plain object first via Object.fromEntries(Array.from(map)).
    final plain = raw == null ? null : object_from_entries(array_from(raw));
    return _convertJsFlagsMap(plain);
  } catch (e) {
    debugPrint('[Mixpanel] getAllVariants failed with error: $e, returning empty map');
    return <String, Map<String, dynamic>>{};
  }
}