tryParse static method

ChatDirectLinkSlug? tryParse(
  1. String val
)

Parses the provided val as a ChatDirectLinkSlug, if val meets the validation, or returns null otherwise.

If val starts with Config.link, then that part is omitted.

Implementation

static ChatDirectLinkSlug? tryParse(String val) {
  if (val.startsWith('${Config.link}/')) {
    val = val.substring(Config.link.length + 1);
  }

  try {
    return ChatDirectLinkSlug(val);
  } catch (_) {
    return null;
  }
}