detectionRegExp function Null safety

RegExp? detectionRegExp(
  1. {bool hashtag = true,
  2. bool atSign = true,
  3. bool url = true}
)

Implementation

RegExp? detectionRegExp({
  bool hashtag = true,
  bool atSign = true,
  bool url = true,
}) {
  if (hashtag == true && atSign == true && url == true) {
    return hashTagAtSignUrlRegExp;
  }
  if (hashtag == true) {
    if (atSign == true) {
      return hashTagAtSignRegExp;
    }
    if (url == true) {
      return hashTagUrlRegExp;
    }
    return hashTagRegExp;
  }

  if (atSign == true) {
    if (url == true) {
      return atSignUrlRegExp;
    }
    return atSignRegExp;
  }

  if (url == true) {
    return urlRegex;
  }
  assert(false,
      "Unexpected condition: hashtag:$hashtag, atSign:$atSign, url:$url");
  return null;
}