extractVariables static method

List<String> extractVariables(
  1. Object? value
)

Extracts the variables names of value.

Implementation

static List<String> extractVariables(Object? value) {
  if (value == null) return [];

  if (value is String) {
    if (value.startsWith('%') && value.endsWith('%')) {
      return [value.substring(1, value.length - 1)];
    }
  } else if (value is WithVariables) {
    return value.requiredVariables;
  } else if (value is List) {
    return value.expand(extractVariables).toList();
  } else if (value is Map) {
    return value.values.expand(extractVariables).toList();
  }

  return [];
}