createUid static method

String createUid({
  1. String? domain,
  2. Uri? organizerUri,
})

Creates a random UID for the given domain.

Instead of the domain you can also specify the organizerUri. When neither the domain nor the organizerUri is specified, a default domain will be appended.

Implementation

static String createUid({String? domain, Uri? organizerUri}) {
  final buffer = StringBuffer();
  _createRandomId(buffer: buffer);
  if (domain == null) {
    if (organizerUri != null) {
      if (organizerUri.host.isNotEmpty) {
        domain = organizerUri.host;
      } else {
        final path = organizerUri.path;
        final atIndex = path.indexOf('@');
        if (atIndex != -1) {
          domain = path.substring(atIndex + 1);
        }
      }
    }
    domain ??= 'enough.de';
  }
  buffer
    ..write('@')
    ..write(domain);
  return buffer.toString();
}