value property

Future<Map<String, T>> value

Gets the map of this ApptimizeMapVariable of the specified type.

Gets the default map provided at construction if no variant has been received from the servers, or the variant map if enrolled in a particular variant.

If a variant is returned, none of the key/value pairs from the default will be returned, even if that key isn’t specified in the variant dictionary.

Returns the default value if there is an issue with the incoming variant data.

Implementation

Future<Map<String, T>> get value async {
  Map<dynamic, dynamic> map =
      await Apptimize._getDynamicVariableValue(name, _type);

  if (map.isEmpty) {
    return Map<String, T>();
  }

  return Map.fromEntries(
      map.entries.map((e) => MapEntry(e.key.toString(), e.value as T)));
}