@@ -43,40 +43,11 @@ class Utils {
4343 // Only keep primitive values
4444 Map <String , dynamic > primitiveMap = {};
4545 for (MapEntry e in map.entries) {
46- if (e.value is String ) {
46+ dynamic processedValue = _processValue (e.value);
47+ if (processedValue != null ) {
4748 primitiveMap[e.key] = e.value;
48- typedMap[e.key] = {
49- Constants .value: e.value,
50- Constants .type: Constants .stringType
51- };
52- continue ;
49+ typedMap[e.key] = processedValue;
5350 }
54- if (e.value is double ) {
55- primitiveMap[e.key] = e.value;
56- typedMap[e.key] = {
57- Constants .value: e.value,
58- Constants .type: Constants .doubleType
59- };
60- continue ;
61- }
62- if (e.value is int ) {
63- primitiveMap[e.key] = e.value;
64- typedMap[e.key] = {
65- Constants .value: e.value,
66- Constants .type: Constants .intType
67- };
68- continue ;
69- }
70- if (e.value is bool ) {
71- primitiveMap[e.key] = e.value;
72- typedMap[e.key] = {
73- Constants .value: e.value,
74- Constants .type: Constants .boolType
75- };
76- continue ;
77- }
78- // ignore: avoid_print
79- print ('Unsupported value type for key: ${e .key }.' );
8051 }
8152
8253 if (Platform .isIOS) {
@@ -85,6 +56,65 @@ class Utils {
8556 return primitiveMap;
8657 }
8758
59+ /// Recursively processes values to add type information for iOS
60+ static dynamic _processValue (dynamic value) {
61+ if (value is String ) {
62+ return {
63+ Constants .value: value,
64+ Constants .type: Constants .stringType
65+ };
66+ }
67+ if (value is double ) {
68+ return {
69+ Constants .value: value,
70+ Constants .type: Constants .doubleType
71+ };
72+ }
73+ if (value is int ) {
74+ return {
75+ Constants .value: value,
76+ Constants .type: Constants .intType
77+ };
78+ }
79+ if (value is bool ) {
80+ return {
81+ Constants .value: value,
82+ Constants .type: Constants .boolType
83+ };
84+ }
85+ if (value is Map ) {
86+ // Handle nested maps
87+ Map <String , dynamic > nestedMap = {};
88+ (value as Map ).forEach ((k, v) {
89+ dynamic processedValue = _processValue (v);
90+ if (processedValue != null ) {
91+ nestedMap[k.toString ()] = processedValue;
92+ }
93+ });
94+ return {
95+ Constants .value: nestedMap,
96+ Constants .type: Constants .mapType
97+ };
98+ }
99+ if (value is List ) {
100+ // Handle arrays
101+ List <dynamic > nestedList = [];
102+ for (var item in value) {
103+ dynamic processedValue = _processValue (item);
104+ if (processedValue != null ) {
105+ nestedList.add (processedValue);
106+ }
107+ }
108+ return {
109+ Constants .value: nestedList,
110+ Constants .type: Constants .listType
111+ };
112+ }
113+ // ignore: avoid_print
114+ print ('Unsupported value type: ${value .runtimeType }' );
115+ return null ;
116+ }
117+
88118 static List <String > convertDecideOptions (
89119 Set <OptimizelyDecideOption > options) {
90120 return options.map ((option) => Utils .decideOptions[option]! ).toList ();
0 commit comments