getDotPath function

String? getDotPath(
  1. StandardIssue issue
)

Returns the dot-notation path of an issue (for example user.tags.1), or null when the issue has no path or any segment is not a string or number.

Direct port of getDotPath from @standard-schema/utils.

Implementation

String? getDotPath(StandardIssue issue) {
  if (issue.path.isEmpty) return null;
  final dotPath = StringBuffer();
  for (final segment in issue.path) {
    final key = segment is StandardPathSegment ? segment.key : segment;
    if (key is String || key is num) {
      if (dotPath.isNotEmpty) dotPath.write('.');
      dotPath.write(key);
    } else {
      return null;
    }
  }
  return dotPath.toString();
}