getContentStringWithName method

Future<String?> getContentStringWithName(
  1. String variableName,
  2. String defaultValue,
  3. int dataType
)

Reads a string Content Optimizer variable.

variableName is the variable defined in the Insider panel, defaultValue is returned when the variable is missing or fetching fails, and dataType is one of ContentOptimizerDataType.CONTENT or ContentOptimizerDataType.ELEMENT.

Implementation

Future<String?> getContentStringWithName(
  String variableName,
  String defaultValue,
  int dataType,
) async {
  try {
    Map<String, dynamic>? args = FlutterInsiderUtils.getContentOptimizerMap(
      variableName,
      defaultValue,
      dataType,
      _channel,
    );
    final String? returnValue = await _channel.invokeMethod(
      Constants.GET_CONTENT_STRING_WITH_NAME,
      args,
    );
    return returnValue;
  } catch (Exception) {
    await FlutterInsiderUtils.putException(_channel, Exception);
    return defaultValue;
  }
}