ariaAttributeValue static method

String? ariaAttributeValue(
  1. Object? value
)

The aria-* attribute value of value (see setAccessibility): null (no attribute), "true"/"false", space-joined, an enum's name, or toString().

Implementation

static String? ariaAttributeValue(Object? value) {
  if (value == null) return null;
  if (value is String) return value;
  if (value is bool) return '$value';
  if (value is Enum) return value.name;
  if (value is Iterable) {
    var buffer = StringBuffer();
    for (var e in value) {
      var s = ariaAttributeValue(e);
      if (s == null || s.isEmpty) continue;
      if (buffer.isNotEmpty) buffer.write(' ');
      buffer.write(s);
    }
    return buffer.toString();
  }
  return '$value';
}